/**************************************************************************/
static void str2lab(char* dest, const char* src, int len, const char* fmt,
- int n)
+ int n)
{
int i,j;
}
if (!rec->image_name && !wpt->icon_descr.isNull()) {
// FIXME: WTH?
-char* t = xstrdup(wpt->icon_descr.toUtf8().data());
+ char* t = xstrdup(wpt->icon_descr.toUtf8().data());
FindIconByName(t, &rec->guid);
-xfree(t);
+ xfree(t);
}
Write_AN1_Waypoint(outfile, rec);
#define BADVAL 999999
static void
-arcdist_arc_disp_wpt_cb(const waypoint *arcpt2)
+arcdist_arc_disp_wpt_cb(const waypoint* arcpt2)
{
queue* elem, * tmp;
waypoint* waypointp;
}
static void
-arcdist_arc_disp_hdr_cb(const route_head *rte)
+arcdist_arc_disp_hdr_cb(const route_head* rte)
{
/* Set arcpt1 to NULL */
arcdist_arc_disp_wpt_cb(NULL);
arcpt2->latitude = arcpt2->longitude = BADVAL;
while ((line = gbfgetstr(file_in))) {
- char * pound = NULL;
+ char* pound = NULL;
int argsfound = 0;
fileline++;
pound = strchr(line, '#');
if (pound) {
if (0 == strncmp(pound, "#break", 6)) {
- arcdist_arc_disp_hdr_cb(NULL);
+ arcdist_arc_disp_hdr_cb(NULL);
}
*pound = '\0';
}
if (argsfound != 2 && strspn(line, " \t\n") < strlen(line)) {
warning(MYNAME ": Warning: Arc file contains unusable vertex on line %d.\n", fileline);
- }
- else {
+ } else {
waypoint* arcpttmp = arcpt1;
arcdist_arc_disp_wpt_cb(arcpt2);
arcpt1 = arcpt2;
wp->latitude = ed->prjlatitude;
wp->route_priority = 1;
if (!arcfileopt &&
- (ed->arcpt2->altitude != unknown_alt) &&
- (ptsopt || (ed->arcpt1->altitude != unknown_alt))) {
+ (ed->arcpt2->altitude != unknown_alt) &&
+ (ptsopt || (ed->arcpt1->altitude != unknown_alt))) {
/* Interpolate alititude */
if (ptsopt) {
wp->altitude = ed->arcpt2->altitude;
} else {
wp->altitude = ed->arcpt1->altitude +
- ed->frac * (ed->arcpt2->altitude - ed->arcpt1->altitude);
+ ed->frac * (ed->arcpt2->altitude - ed->arcpt1->altitude);
}
}
if (trkopt &&
- (ed->arcpt2->GetCreationTime().isValid()) &&
- (ptsopt || (ed->arcpt1->GetCreationTime().isValid()))) {
+ (ed->arcpt2->GetCreationTime().isValid()) &&
+ (ptsopt || (ed->arcpt1->GetCreationTime().isValid()))) {
/* Interpolate time */
if (ptsopt) {
wp->SetCreationTime(ed->arcpt2->GetCreationTime());;
// of the two points. Add that to the first for the
// interpolated time.
int scaled_time = ed->frac *
- ed->arcpt1->GetCreationTime().msecsTo(ed->arcpt2->GetCreationTime());
+ ed->arcpt1->GetCreationTime().msecsTo(ed->arcpt2->GetCreationTime());
QDateTime new_time(ed->arcpt1->GetCreationTime().addMSecs(scaled_time));
wp->SetCreationTime(new_time);
}
double lat_orig_next = RAD(wpt_orig_next->latitude);
double long_orig_next = RAD(wpt_orig_next->longitude);
- waypoint* wpt_dest_next = NULL;
+ waypoint* wpt_dest_next = NULL;
if (is_small_angle(lat_orig, long_orig, lat_orig_prev,
long_orig_prev, lat_orig_next, long_orig_next)) {
}
wpt_dest_next = create_wpt_dest(wpt_orig,
- lat_orig, long_orig, lat_orig_next, long_orig_next);
+ lat_orig, long_orig, lat_orig_next, long_orig_next);
if (wpt_dest_next != NULL) {
route_add_wpt(route_dest, wpt_dest_next);
return res;
}
-const char *
-cet_convert_string(const QString& str) {
+const char*
+cet_convert_string(const QString& str)
+{
// FIXME: this is really weird. Since cet_convert_string wants to free
// its argument (!) we make a duplicate just to satisfy that kind of goofy
// requirement.
w->notes = cet_convert_string(wpt->notes);
if (gc_data) {
- const char *placer = cet_convert_string(gc_data->placer);
- const char *hint = cet_convert_string(gc_data->hint);
+ const char* placer = cet_convert_string(gc_data->placer);
+ const char* hint = cet_convert_string(gc_data->hint);
gc_data->placer = placer;
gc_data->hint = hint;
xfree(placer);
rte->rte_name = cet_convert_string(route->rte_name);
rte->rte_desc = cet_convert_string(route->rte_desc);
- const char*rte_url = cet_convert_string(route->rte_url);
+ const char* rte_url = cet_convert_string(route->rte_url);
rte->rte_url = rte_url;
xfree(rte_url);
}
*n = i;
/* Appropriately size (not zero terminated) buffer */
- utf8 = utf8b = (char *)xmalloc(i);
+ utf8 = utf8b = (char*)xmalloc(i);
for (j = 0; utf8 < utf8b + i; j++) {
utf8 += cet_ucs4_to_utf8(utf8, 6, src[j]);
}
/* We return a NUL terminated string. */
- utf8 = utf8b = (char *)xmalloc(i + 1);
+ utf8 = utf8b = (char*)xmalloc(i + 1);
in = src;
for (j = 0; utf8 < utf8b + i; j++) {
}
// Allocate space
- char_attrs = (const char **)xmalloc((size + 1) * sizeof(char*));
+ char_attrs = (const char**)xmalloc((size + 1) * sizeof(char*));
// Duplicate strings
for (i = 0; i < size; ++i) {
if (wpt->shortname != NULL) {
waypt_add(waypt_dupe(wpt));
- // Rather than creating a new waypt on each read, tis format bizarrely
- // recycles the same one, relying on waypt_dupe() above and then manually
- // resetting fields. Weird.
- wpt->url_link_list_.clear();
+ // Rather than creating a new waypt on each read, tis format bizarrely
+ // recycles the same one, relying on waypt_dupe() above and then manually
+ // resetting fields. Weird.
+ wpt->url_link_list_.clear();
if (temp_route == NULL) {
temp_route = route_head_alloc();
if (strcmp(cin + 2, "note") == 0) {
buff = gbfgetstr(fin);
if (buff == NULL) {
- buff = (char *) "";
+ buff = (char*) "";
}
line++;
cin = lrtrim(buff);
long
time_to_yyyymmdd(QDateTime t)
{
- QDate d = t.date();
- return d.year() * 10000 + d.month() * 100 + d.day();
+ QDate d = t.date();
+ return d.year() * 10000 + d.month() * 100 + d.day();
}
static garmin_fs_t*
wpt->notes = csv_stringtrim(s, "", 0);
break;
case XT_URL:
- if (!link_) link_ = new UrlLink;
+ if (!link_) {
+ link_ = new UrlLink;
+ }
link_->url_ = QString(s).trimmed();
break;
case XT_URL_LINK_TEXT:
- if (!link_) link_ = new UrlLink;
+ if (!link_) {
+ link_ = new UrlLink;
+ }
link_->url_link_text_ = QString(s).trimmed();
break;
case XT_ICON_DESCR:
wpt->SetCreationTime(xml_parse_time(s));
break;
case XT_NET_TIME: {
-fatal("XT_NET_TIME can't have possibly ever worked.");
+ fatal("XT_NET_TIME can't have possibly ever worked.");
// time_t tt = wpt->GetCreationTime();
// dotnet_time_to_time_t(atof(s), &tt, &wpt->microseconds);
- }
- break;
+ }
+ break;
case XT_GEOCACHE_LAST_FOUND:
waypt_alloc_gc_data(wpt)->last_found = yyyymmdd_to_time(s);
break;
}
}
break;
- case XT_URL_LINK_TEXT:
+ case XT_URL_LINK_TEXT:
if (wpt->HasUrlLink()) {
- UrlLink l = wpt->GetUrlLink();
- snprintf(buff, sizeof(buff), fmp->printfc,
- !l.url_link_text_.isEmpty() ? l.url_link_text_.toUtf8().data() : fmp->val);
+ UrlLink l = wpt->GetUrlLink();
+ snprintf(buff, sizeof(buff), fmp->printfc,
+ !l.url_link_text_.isEmpty() ? l.url_link_text_.toUtf8().data() : fmp->val);
}
break;
case XT_ICON_DESCR:
writebuff(buff, fmp->printfc, TIMET_TO_EXCEL(wpt->GetCreationTime().toTime_t()));
break;
case XT_TIMET_TIME:
- /* time as a time_t variable */ {
+ /* time as a time_t variable */
+ {
time_t tt = wpt->GetCreationTime().toTime_t();
- writebuff(buff, fmp->printfc, tt); }
- break;
+ writebuff(buff, fmp->printfc, tt);
+ }
+ break;
case XT_TIMET_TIME_MS: {
/* time as a time_t variable in milliseconds */
char tbuf[24];
writetime(buff, sizeof buff, "%Y-%m-%dT%H:%M:%SZ", wpt->GetCreationTime(), true);
break;
case XT_ISO_TIME_MS:
- strcpy(buff, wpt->GetCreationTime().toPrettyString().toUtf8().data());
+ strcpy(buff, wpt->GetCreationTime().toPrettyString().toUtf8().data());
break;
case XT_GEOCACHE_LAST_FOUND:
writebuff(buff, fmp->printfc, time_to_yyyymmdd(wpt->gc_data->last_found));
gc_small
} geocache_container;
-class utf_string{
- public:
+class utf_string
+{
+public:
utf_string() :
is_html(false)
{};
QString utfstring;
};
-class geocache_data {
- public:
+class geocache_data
+{
+public:
geocache_data() :
id(0),
type(gt_unknown),
fs_convert convert;
} format_specific_data;
-class gb_color {
- public:
+class gb_color
+{
+public:
gb_color() :
bbggrr(-1),
opacity(255) {}
* Structures and functions for multiple URLs per waypoint.
*/
-class UrlLink {
- public:
- UrlLink() { }
- UrlLink(QString url) :
+class UrlLink
+{
+public:
+ UrlLink() { }
+ UrlLink(QString url) :
url_(url)
- { }
- UrlLink(QString url, QString url_link_text) :
+ { }
+ UrlLink(QString url, QString url_link_text) :
url_(url),
url_link_text_(url_link_text)
{ }
/*
* Misc bitfields inside struct waypoint;
*/
-class wp_flags {
- public:
- wp_flags() :
+class wp_flags
+{
+public:
+ wp_flags() :
shortname_is_synthetic(0),
cet_converted(0),
fmt_use(0),
// things, though it's u nlikely to matter in practical terms. Don't use these
// if a false positive would be deleterious.
#
-class global_trait {
- public:
+class global_trait
+{
+public:
global_trait() :
trait_geocaches(0),
trait_heartrate(0),
* way to the target.
*/
-class waypoint {
+class waypoint
+{
+public:
+ waypoint() :
+ latitude(0), // These should probably use some invalid data, but
+ longitude(0), // it looks like we have code that relies on them being zero.
+ altitude(-99999999.0),
+ depth(0),
+ proximity(0),
+ shortname(NULL),
+ description(NULL),
+ notes(NULL),
+ route_priority(0),
+ hdop(0),
+ vdop(0),
+ pdop(0),
+ course(0),
+ speed(0),
+ fix(fix_unknown),
+ sat(-1),
+ heartrate(0),
+ cadence(0),
+ power(0),
+ temperature(0),
+ odometer_distance(0),
+ gc_data(NULL),
+ fs(NULL),
+ session(NULL),
+ extra_data(NULL) { }
public:
- waypoint() :
- latitude(0), // These should probably use some invalid data, but
- longitude(0), // it looks like we have code that relies on them being zero.
- altitude(-99999999.0),
- depth(0),
- proximity(0),
- shortname(NULL),
- description(NULL),
- notes(NULL),
- route_priority(0),
- hdop(0),
- vdop(0),
- pdop(0),
- course(0),
- speed(0),
- fix(fix_unknown),
- sat(-1),
- heartrate(0),
- cadence(0),
- power(0),
- temperature(0),
- odometer_distance(0),
- gc_data(NULL),
- fs(NULL),
- session(NULL),
- extra_data(NULL) { }
- public:
QString CreationTimeXML() const;
queue Q; /* Master waypoint q. Not for use
by modules. */
/* TODO: UrlLink should probably move to a "real" class of its own.
*/
QList<UrlLink> url_link_list_;
- bool HasUrlLink() const {return !url_link_list_.isEmpty(); }
- const UrlLink& GetUrlLink() const { return url_link_list_[0]; }
- const QList<UrlLink> GetUrlLinks() const { return url_link_list_; }
- void AddUrlLink(const UrlLink l) { url_link_list_.push_back(l); }
+ bool HasUrlLink() const {
+ return !url_link_list_.isEmpty();
+ }
+ const UrlLink& GetUrlLink() const {
+ return url_link_list_[0];
+ }
+ const QList<UrlLink> GetUrlLinks() const {
+ return url_link_list_;
+ }
+ void AddUrlLink(const UrlLink l) {
+ url_link_list_.push_back(l);
+ }
wp_flags wpt_flags;
QString icon_descr;
gpsbabel::DateTime GetCreationTime() const {
- return creation_time;
+ return creation_time;
}
- void SetCreationTime(gpsbabel::DateTime t) { creation_time = t;
+ void SetCreationTime(gpsbabel::DateTime t) {
+ creation_time = t;
}
- void SetCreationTime(time_t t) { creation_time = QDateTime::fromTime_t(t);
+ void SetCreationTime(time_t t) {
+ creation_time = QDateTime::fromTime_t(t);
}
void SetCreationTime(time_t t, int ms) {
creation_time.setTime_t(t);
void* extra_data; /* Extra data added by, say, a filter. */
};
-class route_head {
- public:
+class route_head
+{
+public:
route_head() :
rte_name(NULL),
rte_desc(NULL),
void warning(const char*, ...) PRINTFLIKE(1, 2);
void debug_print(int level, const char* fmt, ...) PRINTFLIKE(2,3);
-ff_vecs_t* find_vec(const char *, const char**);
+ff_vecs_t* find_vec(const char*, const char**);
void assign_option(const char* vecname, arglist_t* ap, const char* val);
void disp_vec_options(const char* vecname, arglist_t* ap);
void disp_vecs(void);
ARG_NOMINMAX
},
{"hint_at_end", &opt_hint_at_end, "If true, geocache hint at end of text", NULL, ARGTYPE_BOOL, ARG_NOMINMAX },
- {"gcsym", &opt_gcsym, "If set to 0, prefer user-provided symbols over Groundspeaks ones for geocaches", NULL, ARGTYPE_BOOL, ARG_NOMINMAX, (char *) "1" },
+ {"gcsym", &opt_gcsym, "If set to 0, prefer user-provided symbols over Groundspeaks ones for geocaches", NULL, ARGTYPE_BOOL, ARG_NOMINMAX, (char*) "1" },
ARG_TERMINATOR
};
static unsigned
libusb_os_packet_read(void* buf)
{
- int n = usb_interrupt_read(usb_handle, endpoint_in, (char *) buf, delbin_os_packet_size, 2000);
+ int n = usb_interrupt_read(usb_handle, endpoint_in, (char*) buf, delbin_os_packet_size, 2000);
if (n < 0) {
fatal(MYNAME ": %s\n", usb_strerror());
}
date = ((int)tm.tm_mday * 10000) + ((int)tm.tm_mon * 100) + tm.tm_year;
gbfputint32(date, fout);
milliseconds = ((int)tm.tm_hour * 10000) +
- ((int)tm.tm_min * 100) + tm.tm_sec;
+ ((int)tm.tm_min * 100) + tm.tm_sec;
milliseconds = (milliseconds * 1000) + (wpt->GetCreationTime().time().msec());
gbfputflt(milliseconds, fout);
if (latitude >= 100) {
manual_point = 1;
latitude -= 100;
- }
- else if (latitude <= -100) {
+ } else if (latitude <= -100) {
manual_point = 1;
latitude += 100;
}
if (manual_point) {
waypt_add(wpt);
- }
- else {
+ } else {
track_add_wpt(*track, wpt);
}
}
}
}
if (!link.url_.isEmpty() || !link.url_link_text_.isEmpty()) {
- wpt_tmp->AddUrlLink(link);
+ wpt_tmp->AddUrlLink(link);
}
waypt_add(wpt_tmp);
p = gbfgetc(file_in);
wpt->microseconds = 0;
sprintf(tbuf, "#%d-0", index);
- wpt->shortname = xstrdup(tbuf);
+ wpt->shortname = xstrdup(tbuf);
sprintf(tbuf, "D:%f Cal:%d MS:%f AH:%d MH:%d AC:%d I:%d T:%d",
array[i]->total_distance, array[i]->calories, array[i]->max_speed, array[i]->avg_heart_rate,
array[i]->max_heart_rate, array[i]->avg_cadence, array[i]->intensity, array[i]->trigger_method);
- wpt->description = xstrdup(tbuf);
+ wpt->description = xstrdup(tbuf);
track_add_wpt(trk_head, wpt);
}
/*Allow even if no correct location, no skip if invalid */
array[i]->total_distance, array[i]->calories, array[i]->max_speed, array[i]->avg_heart_rate,
array[i]->max_heart_rate, array[i]->avg_cadence, array[i]->intensity, array[i]->trigger_method,
array[i]->begin_lon, array[i]->begin_lat);
- wpt->description = xstrdup(tbuf);
+ wpt->description = xstrdup(tbuf);
track_add_wpt(trk_head, wpt);
}
writer->writeStartElement("extensions");
writer->writeStartElement("gpxx:WaypointExtension");
writer->writeNamespace("http://www.garmin.com/xmlschemas/GpxExtensions/v3",
- "gpxx");
+ "gpxx");
if WAYPT_HAS(waypt, proximity) {
writer->writeTextElement("gpxx:Proximity", QString::number(waypt->proximity, 'f', 6));
}
if (! garmin_fs_merge_category(cdatastr, waypt)) {
// There's nothing a user can really do about this (well, they could
// create a gpsbabel.ini that mapped them to garmin category numbers
- // but that feature is so obscure and used in so few outputs that
+ // but that feature is so obscure and used in so few outputs that
// there's no reason to alarm the user. Just silently disregard
// category names that don't map cleanly.
// warning(MYNAME ": Unable to convert category \"%s\"!\n", cdatastr);
print_string("%s\t", icon_descr);
if (dynamic) {
// sleaze alert: cast away constness.
- xfree((char *) icon_descr);
+ xfree((char*) icon_descr);
}
print_string("%s\t", GMSD_GET(facility, ""));
time_t ct;
parse_date_and_time(str, &ct);
wpt->SetCreationTime(ct);
- }
- break;
+ }
+ break;
case 17: {
UrlLink l(str);
wpt->AddUrlLink(l);
- }
- break;
+ }
+ break;
case 18:
GMSD_SET(category, parse_categories(str));
break;
time_t ct;
parse_date_and_time(str, &ct);
wpt->SetCreationTime(ct);
- }
- break;
+ }
+ break;
case 3:
if (parse_distance(str, &x, 1, MYNAME)) {
wpt->altitude = x;
int
gbfputpstr(const QString& s, gbfile* file)
{
- const char *t = xstrdup(s.toUtf8().data());
+ const char* t = xstrdup(s.toUtf8().data());
int r = gbfputpstr(t, file);
xfree(t);
return r;
{
gbser_handle* h = gbser__get_handle(handle);
unsigned count = *len;
- unsigned char* cp = (unsigned char *) *buf;
+ unsigned char* cp = (unsigned char*) *buf;
if (count > h->inbuf_used) {
count = h->inbuf_used;
}
{
gbser_handle* h = gbser__get_handle(handle);
DWORD nwritten;
- const char* bp = (const char *) buf;
+ const char* bp = (const char*) buf;
/* Not sure we need to spin here - but this'll work even if we don't */
while (len > 0) {
if (!WriteFile(h->comport, bp, len, &nwritten, NULL)) {
unsigned len, unsigned ms,
int eol, int discard)
{
- char* bp = (char *) buf;
+ char* bp = (char*) buf;
unsigned pos = 0;
hp_time tv;
get_time(&tv);
static QString
gdb_fread_cstr_as_qstr(gbfile* fin)
{
- char* result = gdb_fread_cstr(fin);
- QString qresult = result;
- xfree(result);
- return qresult;
+ char* result = gdb_fread_cstr(fin);
+ QString qresult = result;
+ xfree(result);
+ return qresult;
}
static int
static void
gdb_write_cstr_list(const QString& str)
{
- return gdb_write_cstr_list(str.toLatin1().data());
+ return gdb_write_cstr_list(str.toLatin1().data());
}
static void
// Compensate for most of class waypt still using C strings and needing
// copies anyway.
-char * ShimString(const QString& s)
+char* ShimString(const QString& s)
{
return xstrdup(s.toUtf8().data());
}
-char * ShimString(const QStringRef& s)
+char* ShimString(const QStringRef& s)
{
return xstrdup(s.toString().toUtf8().data());
}
QStringRef tag_name = reader.name();
if (reader.tokenType()==QXmlStreamReader::StartElement) {
if (tag_name == "waypoint") {
- wpt = waypt_new();
- waypt_alloc_gc_data(wpt);
- // There is no 'unknown' alt value and so many reference files have
- // leaked it that we just paper over that here.
- wpt->altitude = 0;
+ wpt = waypt_new();
+ waypt_alloc_gc_data(wpt);
+ // There is no 'unknown' alt value and so many reference files have
+ // leaked it that we just paper over that here.
+ wpt->altitude = 0;
} else if (tag_name == "name") {
QXmlStreamAttributes a = reader.attributes();
wpt->shortname = ShimString(a.value("id"));
wpt->icon_descr = reader.readElementText();
} else if (tag_name == "link") {
QXmlStreamAttributes a = reader.attributes();
- waypt_add_url(wpt,
+ waypt_add_url(wpt,
reader.readElementText(), a.value("text").toString());
} else if (tag_name == "difficulty") {
wpt->gc_data->diff = reader.readElementText().toInt() * 10;
if (reader.tokenType() == QXmlStreamReader::EndElement) {
if (tag_name == "waypoint") {
- waypt_add(wpt);
+ waypt_add(wpt);
}
}
{ NULL, (xg_cb_type)0, NULL }
};
-void goog_script(const char* args, const QXmlStreamAttributes *unused)
+void goog_script(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
if (script) {
}
}
-void goog_points(const char* args, const QXmlStreamAttributes *unused)
+void goog_points(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
if (encoded_points) {
}
}
-void goog_levels(const char* args, const QXmlStreamAttributes *unused)
+void goog_levels(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
if (encoded_levels) {
QStringRef ptidx = attrv->value("pointIndex");
if (!ptidx.isEmpty()) {
snprintf(goog_segname, sizeof(goog_segname), "\\%5.5x",
- ptidx.toString().toUInt());
+ ptidx.toString().toUInt());
}
}
-void goog_segment(const char* args, const QXmlStreamAttributes *unused)
+void goog_segment(const char* args, const QXmlStreamAttributes* unused)
{
waypoint* wpt_tmp;
snprintf(goog_segname, sizeof(goog_segname), "\\%5.5x",
idstr.mid(idstr.lastIndexOf("_") + 1).toUInt() +
- routecount[goog_segroute]);
+ routecount[goog_segroute]);
}
}
return result/2;
}
-void goog_poly_e(const char* args, const QXmlStreamAttributes *unused)
+void goog_poly_e(const char* args, const QXmlStreamAttributes* unused)
{
long lat = 0;
long lon = 0;
char* str = encoded_points;
route_head* routehead = route_head_alloc();
- if (strcmp (args, "overview_polyline") == 0) {
+ if (strcmp(args, "overview_polyline") == 0) {
routehead->rte_name = (char*) xstrdup("overview");
routehead->rte_desc = (char*) xstrdup("Overview");
} else {
speed=0;
if (lastwpt !=NULL) {
speed=3.6*radtometers(gcdist(RAD(lastwpt->latitude), RAD(lastwpt->longitude), RAD(wpt->latitude), RAD(wpt->longitude))) /
- abs(wpt->creation_time.toTime_t() - lastwpt->GetCreationTime().toTime_t());
+ abs(wpt->creation_time.toTime_t() - lastwpt->GetCreationTime().toTime_t());
//printf("speed line %d %lf \n",line,speed);
}
/* Error handling: in the tracklog of my device sometimes "jump" waypoints ;-) */
* known to be positive. */
*prjlat = DEG(asin(yp));
- if(xp == 0 && zp == 0) {
+ if (xp == 0 && zp == 0) {
*prjlon = 0;
- }
- else {
+ } else {
*prjlon = DEG(atan2(zp, xp));
}
*frac = d1/(d1 + d2);
double lat2, double lon2,
double lat3, double lon3,
double* prjlat, double* prjlon,
- double* frac );
+ double* frac);
double linedist(double lat1, double lon1,
double lat2, double lon2,
}
}
static void
-fwrite_string(gbfile* fd, QString& str) {
+fwrite_string(gbfile* fd, QString& str)
+{
if (str.isEmpty()) {
fwrite_integer(fd, 0);
} else {
void set_datum(int n)
{
indatum = -1;
- if (n > 0 && n < MAX_INDATUM_INDEX)
- {
- indatum = indatum_array[n];
+ if (n > 0 && n < MAX_INDATUM_INDEX) {
+ indatum = indatum_array[n];
}
- if (indatum == -1)
- {
+ if (indatum == -1) {
warning(MYNAME ": Unsupported datum (%d), won't convert to WGS84\n", n);
}
}
}
if (tdata->avg_hrt) {
gtc_write_xml(1, "<AverageHeartRateBpm xsi:type=\"HeartRateInBeatsPerMinute_t\">\n");
- gtc_write_xml(0, "<Value>%d</Value>\n", (int) (tdata->avg_hrt + 0.5));
+ gtc_write_xml(0, "<Value>%d</Value>\n", (int)(tdata->avg_hrt + 0.5));
gtc_write_xml(-1,"</AverageHeartRateBpm>\n");
}
if (tdata->max_hrt) {
gtc_write_xml(1, "<MaximumHeartRateBpm xsi:type=\"HeartRateInBeatsPerMinute_t\">\n");
- gtc_write_xml(0, "<Value>%d</Value>\n", (int) (tdata->max_hrt + 0.5));
+ gtc_write_xml(0, "<Value>%d</Value>\n", (int)(tdata->max_hrt + 0.5));
gtc_write_xml(-1,"</MaximumHeartRateBpm>\n");
}
if (tdata->avg_cad) {
route_disp(rte, gtc_study_lap);
if (gtc_least_time.isValid()) {
gtc_write_xml(0, "<Id>%s</Id>\n",
- CSTR(gtc_least_time.toPrettyString()));
+ CSTR(gtc_least_time.toPrettyString()));
gtc_write_xml(1, "<Lap StartTime=\"%s\">\n",
- CSTR(gtc_least_time.toPrettyString()));
+ CSTR(gtc_least_time.toPrettyString()));
} else {
gtc_write_xml(1, "<Lap>\n");
}
if (wpt_tmp->longitude != 0. && wpt_tmp->latitude != 0.) {
/* Add the begin position of a CourseLap as
a waypoint. */
- char *cbuf;
+ char* cbuf;
xasprintf(&cbuf, "LAP%03d", lap_ct);
wpt_tmp->shortname = cbuf;
waypt_add(wpt_tmp);
#define GEOID_SCALE 1.0
#define GEOID_ROW 181
#define GEOID_COL 361
-static const int8_t geoid_delta[GEOID_COL*GEOID_ROW]= {
+static const int8_t geoid_delta[GEOID_COL* GEOID_ROW]= {
/* -180,-179,-178,-177,-176,-175,-174,-173,-172,-171,-170,-169,-168,-167,-166,-165,-164,-163,-162,-161,-160,-159,-158,-157,-156,-155,-154,-153,-152,-151,-150,-149,-148,-147,-146,-145,-144,-143,-142,-141,-140,-139,-138,-137,-136,-135,-134,-133,-132,-131,-130,-129,-128,-127,-126,-125,-124,-123,-122,-121,-120,-119,-118,-117,-116,-115,-114,-113,-112,-111,-110,-109,-108,-107,-106,-105,-104,-103,-102,-101,-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180 */
/* -90.0 */ -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30,
/* -89.0 */ -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30,
};
static gbfile* fin, *fout;
-static QHash<QString, const waypoint *> trkpts;
+static QHash<QString, const waypoint*> trkpts;
static time_t
jtr_parse_time(const char* str, struct tm* tm, int* milli)
if (wpt_tmp_queued) {
waypt_add(wpt_tmp);
} else {
- waypt_free(wpt_tmp);
+ waypt_free(wpt_tmp);
}
wpt_tmp_queued = 0;
}
static void kml_output_timestamp(const waypoint* waypointp)
{
QString time_string = waypointp->CreationTimeXML();
- if(!time_string.isEmpty()) {
+ if (!time_string.isEmpty()) {
writer->writeStartElement("TimeStamp");
AUTOFORMATTING_OFF(af); // FIXME: we turn off autoformatting just to match old writer test references.
writer->writeTextElement("when", time_string);
{
if (kml_altitude_known(waypointp)) {
writer->writeTextElement("coordinates",
- QString::number(waypointp->longitude, 'f', 6) + QString(",") +
- QString::number(waypointp->latitude, 'f', 6) + QString(",") +
- QString::number(waypointp->altitude, 'f', 2)
- );
+ QString::number(waypointp->longitude, 'f', 6) + QString(",") +
+ QString::number(waypointp->latitude, 'f', 6) + QString(",") +
+ QString::number(waypointp->altitude, 'f', 2)
+ );
} else {
writer->writeTextElement("coordinates",
- QString::number(waypointp->longitude, 'f', 6) + QString(",") +
- QString::number(waypointp->latitude, 'f', 6)
- );
+ QString::number(waypointp->longitude, 'f', 6) + QString(",") +
+ QString::number(waypointp->latitude, 'f', 6)
+ );
}
}
*/
if (pt->GetCreationTime().isValid()) {
QString time_string = pt->CreationTimeXML();
- if(!time_string.isEmpty()) {
+ if (!time_string.isEmpty()) {
kml_td(hwriter, QString("Time: %1 ").arg(time_string));
}
}
static void kml_recompute_time_bounds(const waypoint* waypointp)
{
- if (waypointp->GetCreationTime().isValid())
- {
- if(!(kml_time_min.isValid()) ||
+ if (waypointp->GetCreationTime().isValid()) {
+ if (!(kml_time_min.isValid()) ||
(waypointp->GetCreationTime() < kml_time_min)) {
kml_time_min = waypointp->GetCreationTime();
}
if (!(kml_time_max.isValid()) ||
- (waypointp->GetCreationTime() > kml_time_max )) {
+ (waypointp->GetCreationTime() > kml_time_max)) {
kml_time_max = waypointp->GetCreationTime();
}
}
if (rotate_colors) {
kml_step_color();
writer->writeTextElement("color", QString("%1%2")
- .arg(kml_color_sequencer.color.opacity, 2, 16, QChar('0')).arg(kml_color_sequencer.color.bbggrr, 6, 16, QChar('0')));
+ .arg(kml_color_sequencer.color.opacity, 2, 16, QChar('0')).arg(kml_color_sequencer.color.bbggrr, 6, 16, QChar('0')));
writer->writeTextElement("width", opt_line_width);
} else {
if (header->line_color.bbggrr >= 0) {
writer->writeTextElement("color", QString("%1%2")
- .arg(header->line_color.opacity, 2, 16, QChar('0')).arg(header->line_color.bbggrr, 6, 16, QChar('0')));
+ .arg(header->line_color.opacity, 2, 16, QChar('0')).arg(header->line_color.bbggrr, 6, 16, QChar('0')));
}
if (header->line_width >= 0) {
writer->writeTextElement("width", QString::number(header->line_width));
}
if (kml_altitude_known(tpt)) {
writer->writeCharacters(QString::number(tpt->longitude, 'f', 6) + QString(",") +
- QString::number(tpt->latitude, 'f', 6) + QString(",") +
- QString::number(tpt->altitude, 'f', 2) + QString("\n")
- );
+ QString::number(tpt->latitude, 'f', 6) + QString(",") +
+ QString::number(tpt->altitude, 'f', 2) + QString("\n")
+ );
} else {
writer->writeCharacters(QString::number(tpt->longitude, 'f', 6) + QString(",") +
- QString::number(tpt->latitude, 'f', 6) + QString("\n")
- );
+ QString::number(tpt->latitude, 'f', 6) + QString("\n")
+ );
}
}
writer->writeEndElement(); // Close coordinates tag
if (realtime_positioning) {
writer->wrteStartTag("LookAt");
writer->writeTextElement("longitude", QString::number(waypointp->longitude, 'f', 6);
- writer->writeTextElement("latitude", QString::number(waypointp->latitude, 'f', 6);
- writer->writeTextElement("altitude", "1000");
- writer->writeEndElement(); // Close LookAt tag
+ writer->writeTextElement("latitude", QString::number(waypointp->latitude, 'f', 6);
+ writer->writeTextElement("altitude", "1000");
+ writer->writeEndElement(); // Close LookAt tag
}
#endif
QUEUE_FOR_EACH(&header->waypoint_list, elem, tmp) {
- waypoint* wpt = (waypoint *) elem;
+ waypoint* wpt = (waypoint*) elem;
switch (member) {
- case fld_power:
- writer->writeTextElement("gx:value", QString::number(wpt->power, 'f', 1));
- break;
- case fld_cadence:
- writer->writeTextElement("gx:value", QString::number(wpt->cadence));
- break;
- case fld_depth:
- writer->writeTextElement("gx:value", QString::number(wpt->depth, 'f', 1));
- break;
- case fld_heartrate:
- writer->writeTextElement("gx:value", QString::number(wpt->heartrate));
- break;
- case fld_temperature:
- writer->writeTextElement("gx:value", QString::number(wpt->temperature, 'f', 1));
- break;
- default:
- fatal("Bad member type");
+ case fld_power:
+ writer->writeTextElement("gx:value", QString::number(wpt->power, 'f', 1));
+ break;
+ case fld_cadence:
+ writer->writeTextElement("gx:value", QString::number(wpt->cadence));
+ break;
+ case fld_depth:
+ writer->writeTextElement("gx:value", QString::number(wpt->depth, 'f', 1));
+ break;
+ case fld_heartrate:
+ writer->writeTextElement("gx:value", QString::number(wpt->heartrate));
+ break;
+ case fld_temperature:
+ writer->writeTextElement("gx:value", QString::number(wpt->temperature, 'f', 1));
+ break;
+ default:
+ fatal("Bad member type");
}
}
writer->writeEndElement(); // Close SimpleArrayData tag
if (kml_altitude_known(tpt)) {
writer->writeTextElement("gx:coord",
- QString::number(tpt->longitude, 'f', 6) + QString(" ") +
- QString::number(tpt->latitude, 'f', 6) + QString(" ") +
- QString::number(tpt->altitude, 'f', 2)
- );
+ QString::number(tpt->longitude, 'f', 6) + QString(" ") +
+ QString::number(tpt->latitude, 'f', 6) + QString(" ") +
+ QString::number(tpt->altitude, 'f', 2)
+ );
} else {
writer->writeTextElement("gx:coord",
- QString::number(tpt->longitude, 'f', 6) + QString(" ") +
- QString::number(tpt->latitude, 'f', 6)
- );
+ QString::number(tpt->longitude, 'f', 6) + QString(" ") +
+ QString::number(tpt->latitude, 'f', 6)
+ );
}
// Capture interesting traits to see if we need to do an ExtendedData
writer->writeStartElement("SchemaData");
writer->writeAttribute("schemaUrl", "#schema");
- if (has_cadence)
+ if (has_cadence) {
kml_mt_simple_array(header, kmt_cadence, fld_cadence);
+ }
- if (has_depth)
+ if (has_depth) {
kml_mt_simple_array(header, kmt_depth, fld_depth);
+ }
- if (has_heartrate)
+ if (has_heartrate) {
kml_mt_simple_array(header, kmt_heartrate, fld_heartrate);
+ }
- if (has_temperature)
+ if (has_temperature) {
kml_mt_simple_array(header, kmt_temperature, fld_temperature);
+ }
- if (has_power)
+ if (has_power) {
kml_mt_simple_array(header, kmt_power, fld_power);
+ }
writer->writeEndElement(); // Close SchemaData tag
writer->writeEndElement(); // Close ExtendedData tag
static int route_uid;
static int track_uid;
-static waypoint **waypt_table;
+static waypoint** waypt_table;
static int waypt_table_sz, waypt_table_ct;
static char* opt_title;
}
static void
-lowranceusr4_writestr(char *buf, gbfile *file, unsigned int bytes_per_char)
+lowranceusr4_writestr(char* buf, gbfile* file, unsigned int bytes_per_char)
{
unsigned int len = 0;
lowranceusr4_get_timestamp(int jd_number, time_t t)
{
int a, b, c, d, e, m;
- struct tm *ptm, ntm;
+ struct tm* ptm, ntm;
time_t out;
/* get UTC time from time_t */
static void
-lowranceusr4_copy_fsdata(lowranceusr4_fsdata **dest, lowranceusr4_fsdata *src)
+lowranceusr4_copy_fsdata(lowranceusr4_fsdata** dest, lowranceusr4_fsdata* src)
{
- *dest = (lowranceusr4_fsdata *)xmalloc(sizeof(*src));
- **dest = *src;
+ *dest = (lowranceusr4_fsdata*)xmalloc(sizeof(*src));
+ ** dest = *src;
(*dest)->fs.next = NULL;
}
static void
-lowranceusr4_free_fsdata(void *fsdata)
+lowranceusr4_free_fsdata(void* fsdata)
{
xfree(fsdata);
}
static
-lowranceusr4_fsdata *
+lowranceusr4_fsdata*
lowranceusr4_alloc_fsdata(void)
{
- lowranceusr4_fsdata *fsdata = (lowranceusr4_fsdata*) xcalloc(sizeof(*fsdata), 1);
+ lowranceusr4_fsdata* fsdata = (lowranceusr4_fsdata*) xcalloc(sizeof(*fsdata), 1);
fsdata->fs.type = FS_LOWRANCEUSR4;
fsdata->fs.copy = (fs_copy) lowranceusr4_copy_fsdata;
fsdata->fs.destroy = lowranceusr4_free_fsdata;
/* make waypoint shortnames unique */
static char
-same_points(const waypoint *A, const waypoint *B)
+same_points(const waypoint* A, const waypoint* B)
{
return ( /* !!! We are case-sensitive !!! */
(strcmp(A->shortname, B->shortname) == 0) &&
}
static void
-register_waypt(const waypoint *ref)
+register_waypt(const waypoint* ref)
{
int i;
- waypoint *wpt = (waypoint *) ref;
+ waypoint* wpt = (waypoint*) ref;
for (i = 0; i < waypt_table_ct; i++) {
- waypoint *cmp = waypt_table[i];
+ waypoint* cmp = waypt_table[i];
if (same_points(wpt, cmp)) {
return;
wpt->shortname, wpt->description, waypt_table_ct);
}
- waypt_table[waypt_table_ct] = (waypoint *)wpt;
+ waypt_table[waypt_table_ct] = (waypoint*)wpt;
waypt_table_ct++;
}
/* end borrowed from raymarine.c */
static int
-lowranceusr4_find_waypt_index(const waypoint *wpt)
+lowranceusr4_find_waypt_index(const waypoint* wpt)
{
int i;
for (i = 0; i < waypt_table_ct; ++i) {
- if (same_points(wpt, (const waypoint *)waypt_table[i])) {
+ if (same_points(wpt, (const waypoint*)waypt_table[i])) {
return i;
}
}
waypoint* wpt_tmp;
wpt_tmp = waypt_new();
- lowranceusr4_fsdata *fsdata = lowranceusr4_alloc_fsdata();
- fs_chain_add(&(wpt_tmp->fs), (format_specific_data *) fsdata);
+ lowranceusr4_fsdata* fsdata = lowranceusr4_alloc_fsdata();
+ fs_chain_add(&(wpt_tmp->fs), (format_specific_data*) fsdata);
/* read/parse waypoint, with fields as follows (taken mostly
from http://lowranceusrv4togpxconverter.blogspot.com/):
// or set it.
if (create_date > 2440587) {
wpt_tmp->SetCreationTime(lowranceusr4_get_timestamp(create_date,
- create_time));
+ create_time));
}
/* Unused byte */
static waypoint*
lowranceusr4_find_waypt(int uid_unit, int uid_seq_low, int uid_seq_high)
{
- queue *elem, *tmp;
- waypoint *waypointp;
- lowranceusr4_fsdata *fs = NULL;
+ queue* elem, *tmp;
+ waypoint* waypointp;
+ lowranceusr4_fsdata* fs = NULL;
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- waypointp = (waypoint *) elem;
- fs = (lowranceusr4_fsdata *) fs_chain_find(waypointp->fs, FS_LOWRANCEUSR4);
+ waypointp = (waypoint*) elem;
+ fs = (lowranceusr4_fsdata*) fs_chain_find(waypointp->fs, FS_LOWRANCEUSR4);
if (fs && fs->uid_unit == uid_unit &&
fs->uid_seq_low == uid_seq_low &&
- fs->uid_seq_high == uid_seq_high)
- {
+ fs->uid_seq_high == uid_seq_high) {
return waypointp;
}
}
route_add_head(rte_head);
rte_head->rte_num = i+1;
- lowranceusr4_fsdata *fsdata = lowranceusr4_alloc_fsdata();
- fs_chain_add(&(rte_head->fs), (format_specific_data *) fsdata);
+ lowranceusr4_fsdata* fsdata = lowranceusr4_alloc_fsdata();
+ fs_chain_add(&(rte_head->fs), (format_specific_data*) fsdata);
/* read/parse route, with fields as follows (taken mostly
from http://lowranceusrv4togpxconverter.blogspot.com/):
trk_head->rte_num = ++trk_num;
track_add_head(trk_head);
- lowranceusr4_fsdata *fsdata = lowranceusr4_alloc_fsdata();
- fs_chain_add(&(trk_head->fs), (format_specific_data *) fsdata);
+ lowranceusr4_fsdata* fsdata = lowranceusr4_alloc_fsdata();
+ fs_chain_add(&(trk_head->fs), (format_specific_data*) fsdata);
/* read/parse trail, with fields as follows (taken mostly from
http://lowranceusrv4togpxconverter.blogspot.com/):
printf(MYNAME " writing out waypt %d (%s - %s)\n",
i, waypt_table[i]->shortname, waypt_table[i]->description);
}
- lowranceusr4_waypt_disp((const waypoint *)waypt_table[i]);
+ lowranceusr4_waypt_disp((const waypoint*)waypt_table[i]);
}
}
short int MajorVersion, MinorVersion;
int DataStreamVersion;
time_t now;
- struct tm *now_tm;
+ struct tm* now_tm;
char buf[256];
setshort_length(mkshort_handle, 15);
int d = date.mid(0,2).toInt();
int m = date.mid(2,2).toInt();
int y = date.mid(4,3).toInt();
- QDateTime r(QDate (y + 1900, m, d));
+ QDateTime r(QDate(y + 1900, m, d));
return r;
}
}
for (i = icon_mapping; i->token; i++) {
- if (icon.compare(i->icon, Qt::CaseInsensitive) == 0) {
+ if (icon.compare(i->icon, Qt::CaseInsensitive) == 0) {
return i->token;
}
}
ovecs->position_ops.wr_deinit();
}
exit(0);
-printf("early\n");
}
static QHash<QString, int> category_names;
static QHash<int, QString> icons;
-static QHash<int, mmo_data_t *> objects;
+static QHash<int, mmo_data_t*> objects;
static QHash<QString, unsigned> mmobjects;
typedef struct mmo_icon_mapping_s {
len = (unsigned)gbfgetc(fin);
if (len > 0) {
unsigned int ii, jj, ch, resbytes=0;
- res = (char *) xmalloc(len*2 + 1); // bigger to allow for utf-8 expansion
+ res = (char*) xmalloc(len*2 + 1); // bigger to allow for utf-8 expansion
for (ii=0; ii<len; ii++) {
char utf8buf[8];
int utf8len;
// positive values of len are for strings longer than 254, handled below:
}
// length zero returns an empty string
- res = (char *) xmalloc(len + 1);
+ res = (char*) xmalloc(len + 1);
res[len] = '\0';
if (len) {
gbfread(res, len, 1, fin);
}
static void
-mmo_free_object(mmo_data_t *data)
+mmo_free_object(mmo_data_t* data)
{
if (data->name) {
xfree(data->name);
icons.clear();
- foreach (int k, objects.keys()) {
+ foreach(int k, objects.keys()) {
mmo_free_object(objects.value(k));
}
objects.clear();
mmobjects.clear();
category_names.clear();
- foreach (int k, objects.keys()) {
+ foreach(int k, objects.keys()) {
mmo_free_object(objects.value(k));
}
objects.clear();
// Tobias Verbree reports that an M-12ee is like a 245.
if (memcmp(&buf[i], "HOLUXM1200", 10) == 0) {
- dbg(2, "Detected Holux HOLUXM1200 !\n");
- holux245_init();
+ dbg(2, "Detected Holux HOLUXM1200 !\n");
+ holux245_init();
}
// skip the 4 spaces that may occur on every device
}
static void
-NaviReadCache(const QXmlStreamReader& reader) {
+NaviReadCache(const QXmlStreamReader& reader)
+{
const QXmlStreamAttributes a = reader.attributes();
waypoint* wpt_tmp = waypt_new();
geocache_data* gc_data;
reader.setDevice(&file);
while (!reader.atEnd()) {
- if (reader.name() == "CacheDetails" &&
- reader.tokenType() == QXmlStreamReader::StartElement) {
+ if (reader.name() == "CacheDetails" &&
+ reader.tokenType() == QXmlStreamReader::StartElement) {
NaviReadCache(reader);
}
reader.readNextStartElement();
unsigned src;
unsigned sr;
unsigned char id[1];
- const char *rte_name;
+ const char* rte_name;
rte_name = route->rte_name;
- if (rte_name == NULL)
+ if (rte_name == NULL) {
rte_name = "NO NAME";
+ }
if (route_id_ptr > MAX_ROUTE_LENGTH) {
fatal(MYNAME ": Route %s too long\n", route->rte_name);
}
rte = route_head_alloc();
if (attrv->hasAttribute("id")) {
- xasprintf(&rte->rte_desc, "osm-id %s",
- attrv->value("id").toString().toUtf8().constData());
+ xasprintf(&rte->rte_desc, "osm-id %s",
+ attrv->value("id").toString().toUtf8().constData());
}
}
for (i = 0; osm_icon_mappings[i].value; i++) {
icons.insert(QString::fromUtf8(osm_icon_mappings[i].icon),
- &osm_icon_mappings[i]);
+ &osm_icon_mappings[i]);
}
}
osm_name_from_wpt(const waypoint* wpt)
{
QString name = QString("%1\01%2\01%3")
- .arg((wpt->shortname) ? wpt->shortname : "")
- .arg(wpt->latitude)
- .arg(wpt->longitude);
+ .arg((wpt->shortname) ? wpt->shortname : "")
+ .arg(wpt->latitude)
+ .arg(wpt->longitude);
return name;
}
} ozi_fsdata;
-static gbfile *file_in, *file_out;
+static gbfile* file_in, *file_out;
static short_handle mkshort_handle;
-static route_head *trk_head;
-static route_head *rte_head;
+static route_head* trk_head;
+static route_head* rte_head;
static int track_out_count;
static int route_out_count;
static int route_wpt_count;
static int new_track;
-static char *snlenopt = NULL;
-static char *snwhiteopt = NULL;
-static char *snupperopt = NULL;
-static char *snuniqueopt = NULL;
-static char *wptfgcolor = NULL;
-static char *wptbgcolor = NULL;
-static char *pack_opt = NULL;
+static char* snlenopt = NULL;
+static char* snwhiteopt = NULL;
+static char* snupperopt = NULL;
+static char* snuniqueopt = NULL;
+static char* wptfgcolor = NULL;
+static char* wptbgcolor = NULL;
+static char* pack_opt = NULL;
static int datum;
-static char *proximityarg = NULL;
+static char* proximityarg = NULL;
static double proximity;
-static char *altunit_opt;
-static char *proxunit_opt;
+static char* altunit_opt;
+static char* proxunit_opt;
static char altunit;
static char proxunit;
static double alt_scale;
static gpsdata_type ozi_objective;
-static char *ozi_ofname = NULL;
+static char* ozi_ofname = NULL;
static void
-ozi_copy_fsdata(ozi_fsdata **dest, ozi_fsdata *src)
+ozi_copy_fsdata(ozi_fsdata** dest, ozi_fsdata* src)
{
/* No strings to mess with. Straight forward copy. */
- *dest = (ozi_fsdata *)xmalloc(sizeof(*src));
- **dest = *src;
+ *dest = (ozi_fsdata*)xmalloc(sizeof(*src));
+ ** dest = *src;
(*dest)->fs.next = NULL;
}
static void
-ozi_free_fsdata(void *fsdata)
+ozi_free_fsdata(void* fsdata)
{
xfree(fsdata);
}
static
-ozi_fsdata *
+ozi_fsdata*
ozi_alloc_fsdata(void)
{
- ozi_fsdata *fsdata = (ozi_fsdata*) xcalloc(sizeof(*fsdata), 1);
+ ozi_fsdata* fsdata = (ozi_fsdata*) xcalloc(sizeof(*fsdata), 1);
fsdata->fs.type = FS_OZI;
fsdata->fs.copy = (fs_copy) ozi_copy_fsdata;
fsdata->fs.destroy = ozi_free_fsdata;
}
void
-ozi_get_time_str(const waypoint *waypointp, char *buff, gbsize_t buffsz)
+ozi_get_time_str(const waypoint* waypointp, char* buff, gbsize_t buffsz)
{
if (waypointp->creation_time.isValid()) {
double time = (waypt_time(waypointp) / SECONDS_PER_DAY) + DAYS_SINCE_1990;
}
void
-ozi_set_time_str(const char *str, waypoint *waypointp)
+ozi_set_time_str(const char* str, waypoint* waypointp)
{
double ozi_time = atof(str);
- if(ozi_time > DAYS_SINCE_1990) {
+ if (ozi_time > DAYS_SINCE_1990) {
waypointp->SetCreationTime((ozi_time - DAYS_SINCE_1990) * SECONDS_PER_DAY,
lround(1000.0 * (ozi_time - (int) ozi_time)));
}
}
static void
-ozi_convert_datum(waypoint *wpt)
+ozi_convert_datum(waypoint* wpt)
{
if (datum != DATUM_WGS84) {
double lat, lon, alt;
}
static void
-ozi_openfile(char *fname)
+ozi_openfile(char* fname)
{
- char *c, *cx, *tmpname;
- const char *ozi_extensions[] = {0, "plt", "wpt", "rte"};
+ char* c, *cx, *tmpname;
+ const char* ozi_extensions[] = {0, "plt", "wpt", "rte"};
char buff[32];
/* if we're doing multi-track output, sequence the filenames like:
}
static void
-ozi_track_hdr(const route_head * rte)
+ozi_track_hdr(const route_head* rte)
{
- static const char *ozi_trk_header =
+ static const char* ozi_trk_header =
"OziExplorer Track Point File Version 2.1\r\n"
"WGS 84\r\n"
"Altitude is in %s\r\n"
}
static void
-ozi_track_disp(const waypoint * waypointp)
+ozi_track_disp(const waypoint* waypointp)
{
double alt;
char ozi_time[16];
}
static void
-ozi_track_tlr(const route_head * rte)
+ozi_track_tlr(const route_head* rte)
{
}
}
static void
-ozi_route_hdr(const route_head * rte)
+ozi_route_hdr(const route_head* rte)
{
- static const char *ozi_route_header =
+ static const char* ozi_route_header =
"OziExplorer Route File Version 1.0\r\n"
"WGS 84\r\n"
"Reserved 1\r\n"
}
static void
-ozi_route_disp(const waypoint * waypointp)
+ozi_route_disp(const waypoint* waypointp)
{
double alt;
char ozi_time[16];
}
static void
-ozi_route_tlr(const route_head * rte)
+ozi_route_tlr(const route_head* rte)
{
}
}
static void
-rd_init(const char *fname)
+rd_init(const char* fname)
{
file_in = gbfopen(fname, "rb", MYNAME);
}
static void
-wr_init(const char *fname)
+wr_init(const char* fname)
{
/* At this point, we have no idea whether we'll be writing waypoint,
* we're actually ready to write.
*/
- ozi_ofname = (char *)fname;
+ ozi_ofname = (char*)fname;
mkshort_handle = mkshort_new_handle();
}
static void
-ozi_parse_waypt(int field, char *str, waypoint * wpt_tmp, ozi_fsdata *fsdata)
+ozi_parse_waypt(int field, char* str, waypoint* wpt_tmp, ozi_fsdata* fsdata)
{
double alt;
}
static void
-ozi_parse_track(int field, char *str, waypoint * wpt_tmp, char *trk_name)
+ozi_parse_track(int field, char* str, waypoint* wpt_tmp, char* trk_name)
{
double alt;
}
static void
-ozi_parse_routepoint(int field, char *str, waypoint * wpt_tmp)
+ozi_parse_routepoint(int field, char* str, waypoint* wpt_tmp)
{
if (*str == '\0') {
return;
}
static void
-ozi_parse_routeheader(int field, char *str, waypoint * wpt_tmp)
+ozi_parse_routeheader(int field, char* str, waypoint* wpt_tmp)
{
switch (field) {
static void
data_read(void)
{
- char *buff;
- char *s = NULL;
- char *trk_name = NULL;
- waypoint *wpt_tmp;
+ char* buff;
+ char* s = NULL;
+ char* trk_name = NULL;
+ waypoint* wpt_tmp;
int i;
int linecount = 0;
}
} else if (linecount == 3) {
if (case_ignore_strncmp(buff, "Altitude is in ", 15) == 0) {
- char *unit = &buff[15];
+ char* unit = &buff[15];
if (case_ignore_strncmp(unit, "Feet", 4) == 0) {
altunit = 'f';
alt_scale = FEET_TO_METERS(1.0);
if ((strlen(buff)) && (strstr(buff, ",") != NULL)) {
bool ozi_fsdata_used = false;
- ozi_fsdata *fsdata = ozi_alloc_fsdata();
+ ozi_fsdata* fsdata = ozi_alloc_fsdata();
wpt_tmp = waypt_new();
/* data delimited by commas, possibly enclosed in quotes. */
switch (ozi_objective) {
case trkdata:
if (linecount > 6) {/* skipping over file header */
- ozi_convert_datum(wpt_tmp);
- track_add_wpt(trk_head, wpt_tmp);
+ ozi_convert_datum(wpt_tmp);
+ track_add_wpt(trk_head, wpt_tmp);
} else {
waypt_free(wpt_tmp);
}
if (linecount > 4) { /* skipping over file header */
ozi_fsdata_used = true;
fs_chain_add(&(wpt_tmp->fs),
- (format_specific_data *) fsdata);
+ (format_specific_data*) fsdata);
ozi_convert_datum(wpt_tmp);
waypt_add(wpt_tmp);
} else {
}
if (!ozi_fsdata_used) {
- fs_chain_destroy((format_specific_data *) fsdata);
+ fs_chain_destroy((format_specific_data*) fsdata);
}
} else {
}
static void
-ozi_waypt_pr(const waypoint * wpt)
+ozi_waypt_pr(const waypoint* wpt)
{
static int index = 0;
double alt;
char ozi_time[16];
- char *description;
- char *shortname;
+ char* description;
+ char* shortname;
int faked_fsdata = 0;
- ozi_fsdata *fs = NULL;
+ ozi_fsdata* fs = NULL;
int icon = 0;
- fs = (ozi_fsdata *) fs_chain_find(wpt->fs, FS_OZI);
+ fs = (ozi_fsdata*) fs_chain_find(wpt->fs, FS_OZI);
if (!fs) {
fs = ozi_alloc_fsdata();
static void
data_write(void)
{
- static const char *ozi_wpt_header =
+ static const char* ozi_wpt_header =
"OziExplorer Waypoint File Version 1.1\r\n"
"WGS 84\r\n"
"Reserved 2\r\n"
*/
int
-parse_distance(const char *str, double *val, double scale, const char *module)
+parse_distance(const char* str, double* val, double scale, const char* module)
{
- char *unit;
+ char* unit;
if ((str == NULL) || (*str == '\0')) {
return 0;
* module: calling module, i.e. "garmin_txt"
*/
int
-parse_speed(const char *str, double *val, const double scale, const char *module)
+parse_speed(const char* str, double* val, const double scale, const char* module)
{
- char *unit;
+ char* unit;
if ((str == NULL) || (*str == '\0')) {
return 0;
*/
int
-parse_coordinates(const char *str, int datum, const grid_type grid,
- double *latitude, double *longitude, const char *module)
+parse_coordinates(const char* str, int datum, const grid_type grid,
+ double* latitude, double* longitude, const char* module)
{
double lat, lon;
unsigned char lathemi, lonhemi;
char utmc;
int valid, result, ct;
double lx, ly;
- const char *format;
+ const char* format;
valid = 1;
#include "garmin_tables.h"
#include "csv_util.h"
-static gbfile *file_in, *file_out;
+static gbfile* file_in, *file_out;
static short_handle mkshort_handle;
static short_handle mkshort_handle2; /* for track and route names */
-static char *deficon = NULL;
-static char *cartoexploreur;
+static char* deficon = NULL;
+static char* cartoexploreur;
static int read_as_degrees;
static int read_gpsu;
static int route_ctr;
};
static void
-rd_init(const char *fname)
+rd_init(const char* fname)
{
file_in = gbfopen(fname, "rb", MYNAME);
}
}
static void
-wr_init(const char *fname)
+wr_init(const char* fname)
{
file_out = gbfopen(fname, "w", MYNAME);
mkshort_handle = mkshort_new_handle();
char date[10];
char time[9];
char month[4];
- waypoint *wpt_tmp;
- char *buff;
+ waypoint* wpt_tmp;
+ char* buff;
struct tm tm;
- route_head *track = NULL;
- route_head *route = NULL;
+ route_head* track = NULL;
+ route_head* route = NULL;
int n;
char lathemi, lonhemi;
char tbuf[20];
points = 0;
while ((buff = gbfgetstr(file_in))) {
- char *ibuf = lrtrim(buff);
- char *cp;
+ char* ibuf = lrtrim(buff);
+ char* cp;
if ((line++ == 0) && file_in->unicode) {
cet_convert_init(CET_CHARSET_UTF8, 1);
// where our other columns start.
case 'F': {
int col;
- char *i = ibuf;
+ char* i = ibuf;
sym_col = 0;
for (col = 0, i = ibuf; *i; col++, i++) {
}
static void
-gpsutil_disp(const waypoint *wpt)
+gpsutil_disp(const waypoint* wpt)
{
double lon,lat;
int icon_token = 0;
}
static void
-pcx_track_hdr(const route_head *trk)
+pcx_track_hdr(const route_head* trk)
{
- char *name;
+ char* name;
char buff[20];
route_ctr++;
}
static void
-pcx_route_hdr(const route_head *rte)
+pcx_route_hdr(const route_head* rte)
{
- char *name;
+ char* name;
char buff[20];
route_ctr++;
}
void
-pcx_track_disp(const waypoint *wpt)
+pcx_track_disp(const waypoint* wpt)
{
double lon,lat;
char tbuf[100];
- struct tm *tm;
- char *tp;
+ struct tm* tm;
+ char* tp;
lon = degrees2ddmm(wpt->longitude);
lat = degrees2ddmm(wpt->latitude);
uint16_t reserve2; // 0x0000
} BREADCRUMB;
-static gbfile *file_in, *file_out;
+static gbfile* file_in, *file_out;
static void
-rd_init(const char *fname)
+rd_init(const char* fname)
{
file_in = gbfopen_le(fname, "rb", MYNAME);
}
}
static void
-wr_init(const char *fname)
+wr_init(const char* fname)
{
file_out = gbfopen_le(fname, "wb", MYNAME);
}
read_tracks(void)
{
struct breadcrumb bc;
- route_head *trk_head = route_head_alloc();
+ route_head* trk_head = route_head_alloc();
trk_head->rte_num = 1;
trk_head->rte_name = xstrdup("PocketFMS");
trk_head->rte_desc = xstrdup("Breadcrumb");
while (1 == gbfread(&bc, sizeof(bc), 1, file_in)) {
struct tm tm;
- waypoint *wpt;
+ waypoint* wpt;
if (strcmp(bc.id, header_id) != 0) {
fatal(MYNAME ": invalid breadcrumb header in input file.\n");
wpt->pdop = le_read_float(&bc.espe);
wpt->course = le_read_float(&bc.course);
wpt->speed = le_read_float(&bc.speed);
- wpt->fix = (fix_type) (le_readu16(&bc.fix) - 1);
+ wpt->fix = (fix_type)(le_readu16(&bc.fix) - 1);
track_add_wpt(trk_head, wpt);
}
}
static void
-route_head_noop(const route_head *wp)
+route_head_noop(const route_head* wp)
{
}
static void
-pocketfms_waypt_disp(const waypoint *wpt)
+pocketfms_waypt_disp(const waypoint* wpt)
{
struct breadcrumb bc;
- struct tm *tm;
+ struct tm* tm;
memset(&bc, 0, sizeof(bc));
const time_t tt = wpt->GetCreationTime().toTime_t();
#include "xmlgeneric.h"
static int isFirst = 1;
-static route_head *route = NULL;
-static waypoint *wpt_to, *wpt_from;
+static route_head* route = NULL;
+static waypoint* wpt_to, *wpt_from;
static double dest_altitude;
#define MYNAME "PocketFMS FlightPlan"
};
static void
-rd_init(const char *fname)
+rd_init(const char* fname)
{
xml_init(fname, gl_map, NULL);
}
rd_deinit(void)
{
if (route != NULL) {
- waypoint *head = (waypoint *) QUEUE_FIRST(&route->waypoint_list);
- waypoint *tail = (waypoint *) QUEUE_LAST(&route->waypoint_list);
+ waypoint* head = (waypoint*) QUEUE_FIRST(&route->waypoint_list);
+ waypoint* tail = (waypoint*) QUEUE_LAST(&route->waypoint_list);
if (head != NULL) {
route->rte_name = xstrdup(head->shortname);
}
}
static void
-wr_init(const char *fname)
+wr_init(const char* fname)
{
fatal("Writing file of type %s is not supported\n", MYNAME);
}
-void wpt_s(const char *args, const QXmlStreamAttributes* unused)
+void wpt_s(const char* args, const QXmlStreamAttributes* unused)
{
if (isFirst == 1) {
wpt_from = waypt_new();
wpt_to = waypt_new();
}
-void wpt_e(const char *args, const QXmlStreamAttributes* unused)
+void wpt_e(const char* args, const QXmlStreamAttributes* unused)
{
if (isFirst == 1) {
route_add_wpt(route, wpt_from);
wpt_to = NULL;
}
-void wpt_from_lat(const char *args, const QXmlStreamAttributes* unused)
+void wpt_from_lat(const char* args, const QXmlStreamAttributes* unused)
{
if (wpt_from != NULL) {
wpt_from->latitude = atof(args);
}
}
-void wpt_from_lon(const char *args, const QXmlStreamAttributes* unused)
+void wpt_from_lon(const char* args, const QXmlStreamAttributes* unused)
{
if (wpt_from != NULL) {
wpt_from->longitude = atof(args);
}
}
-void wpt_from_name(const char *args, const QXmlStreamAttributes* unused)
+void wpt_from_name(const char* args, const QXmlStreamAttributes* unused)
{
if (wpt_from != NULL) {
wpt_from->shortname = xstrappend(wpt_from->shortname, args);
}
}
-void wpt_from_elev(const char *args, const QXmlStreamAttributes* unused)
+void wpt_from_elev(const char* args, const QXmlStreamAttributes* unused)
{
if (wpt_from != NULL) {
wpt_from->altitude = FEET_TO_METERS(atof(args));
}
}
-void wpt_to_lat(const char *args, const QXmlStreamAttributes* unused)
+void wpt_to_lat(const char* args, const QXmlStreamAttributes* unused)
{
wpt_to->latitude = atof(args);
}
-void wpt_to_lon(const char *args, const QXmlStreamAttributes* unused)
+void wpt_to_lon(const char* args, const QXmlStreamAttributes* unused)
{
wpt_to->longitude = atof(args);
}
-void wpt_to_name(const char *args, const QXmlStreamAttributes* unused)
+void wpt_to_name(const char* args, const QXmlStreamAttributes* unused)
{
wpt_to->shortname = xstrappend(wpt_to->shortname, args);
}
-void wpt_to_elev(const char *args, const QXmlStreamAttributes* unused)
+void wpt_to_elev(const char* args, const QXmlStreamAttributes* unused)
{
dest_altitude = FEET_TO_METERS(atof(args));
}
-void wpt_altitude(const char *args, const QXmlStreamAttributes* attrv)
+void wpt_altitude(const char* args, const QXmlStreamAttributes* attrv)
{
int isFeet = 0;
#define MYNAME "PocketFMS waypoint text file format"
-static gbfile *file_in, *file_out;
+static gbfile* file_in, *file_out;
static void
-rd_init(const char *fname)
+rd_init(const char* fname)
{
file_in = gbfopen_le(fname, "r", MYNAME);
}
-double wppos_to_dec(char *value)
+double wppos_to_dec(char* value)
{
if (strstr(value, "\xB0") == NULL) {
return atof(value);
static void
data_read(void)
{
- char *buff;
+ char* buff;
int linecount = 0;
while ((buff = gbfgetstr(file_in))) {
- char *s;
- waypoint *wpt;
+ char* s;
+ waypoint* wpt;
rtrim(buff);
if (strlen(buff) == 0) {
break;
}
static void
-wr_init(const char *fname)
+wr_init(const char* fname)
{
file_out = gbfopen_le(fname, "w", MYNAME);
}
static void
-enigma_waypt_disp(const waypoint *wpt)
+enigma_waypt_disp(const waypoint* wpt)
{
- char *t;
+ char* t;
if (wpt->shortname) {
// The output might have a space or control character.
int i, l = strlen(wpt->shortname);
t = (char*) xmalloc(l + 1);
- char *d = t;
+ char* d = t;
for (i = 0; i < l; i++) {
char s = wpt->shortname[i];
- if(isgraph(s)) {
+ if (isgraph(s)) {
*d++ = s;
}
}
#if FILTERS_ENABLED
#define MYNAME "Polygon filter"
-static char *polyfileopt = NULL;
-static char *exclopt = NULL;
+static char* polyfileopt = NULL;
+static char* exclopt = NULL;
/*
* This test for insideness is essentially an odd/even test. The
static void polytest(double lat1, double lon1,
double lat2, double lon2,
double wlat, double wlon,
- unsigned short *state, int first, int last)
+ unsigned short* state, int first, int last)
{
if (lat1 == wlat) {
void
polygon_process(void)
{
- queue * elem, * tmp;
- waypoint * waypointp;
- extra_data *ed;
+ queue* elem, * tmp;
+ waypoint* waypointp;
+ extra_data* ed;
double lat1, lon1, lat2, lon2;
double olat, olon;
int fileline = 0;
int first = 1;
int last = 0;
- char *line;
- gbfile *file_in;
+ char* line;
+ gbfile* file_in;
file_in = gbfopen(polyfileopt, "r", MYNAME);
olat = olon = lat1 = lon1 = lat2 = lon2 = BADVAL;
while ((line = gbfgetstr(file_in))) {
- char *pound = NULL;
+ char* pound = NULL;
int argsfound = 0;
fileline++;
foreach(waypoint* waypointp, waypt_list) {
#else
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- waypointp = (waypoint *)elem;
+ waypointp = (waypoint*)elem;
#endif
if (waypointp->extra_data) {
- ed = (extra_data *) waypointp->extra_data;
+ ed = (extra_data*) waypointp->extra_data;
} else {
- ed = (extra_data *) xcalloc(1, sizeof(*ed));
+ ed = (extra_data*) xcalloc(1, sizeof(*ed));
ed->state = OUTSIDE;
ed->override = 0;
- waypointp->extra_data = (extra_data *) ed;
+ waypointp->extra_data = (extra_data*) ed;
}
if (lat2 == waypointp->latitude &&
lon2 == waypointp->longitude) {
foreach(waypoint* wp, waypt_list) {
#else
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- waypoint *wp = (waypoint *) elem;
+ waypoint* wp = (waypoint*) elem;
#endif
- ed = (extra_data *) wp->extra_data;
+ ed = (extra_data*) wp->extra_data;
wp->extra_data = NULL;
if (ed) {
if (ed->override) {
}
void
-polygon_init(const char *args)
+polygon_init(const char* args)
{
/* do nothing */
}
# define M_PI 3.14159265358979323846
#endif
-static route_head *cur_rte = NULL;
+static route_head* cur_rte = NULL;
static double pos_dist;
static double max_diff_time;
-static char *distopt = NULL;
-static char *timeopt = NULL;
-static char *purge_duplicates = NULL;
+static char* distopt = NULL;
+static char* timeopt = NULL;
+static char* purge_duplicates = NULL;
static int check_time;
typedef struct {
/* tear through a waypoint queue, processing points by distance */
static void
-position_runqueue(queue *q, int nelems, int qtype)
+position_runqueue(queue* q, int nelems, int qtype)
{
- queue * elem, * tmp;
- waypoint ** comp;
- int * qlist;
+ queue* elem, * tmp;
+ waypoint** comp;
+ int* qlist;
double dist, diff_time;
int i = 0, j, anyitem;
- comp = (waypoint **) xcalloc(nelems, sizeof(*comp));
- qlist = (int *) xcalloc(nelems, sizeof(*qlist));
+ comp = (waypoint**) xcalloc(nelems, sizeof(*comp));
+ qlist = (int*) xcalloc(nelems, sizeof(*qlist));
QUEUE_FOR_EACH(q, elem, tmp) {
- comp[i] = (waypoint *)elem;
+ comp[i] = (waypoint*)elem;
qlist[i] = 0;
i++;
}
}
static void
-position_process_route(const route_head * rh)
+position_process_route(const route_head* rh)
{
int i = rh->rte_waypt_ct;
if (i) {
- cur_rte = (route_head *)rh;
- position_runqueue((queue *)&rh->waypoint_list, i, rtedata);
+ cur_rte = (route_head*)rh;
+ position_runqueue((queue*)&rh->waypoint_list, i, rtedata);
cur_rte = NULL;
}
}
static void
-position_noop_w(const waypoint *w)
+position_noop_w(const waypoint* w)
{
}
static void
-position_noop_t(const route_head *h)
+position_noop_t(const route_head* h)
{
}
}
void
-position_init(const char *args)
+position_init(const char* args)
{
- char *fm;
+ char* fm;
pos_dist = 0;
max_diff_time = 0;
typedef struct psit_icon_mapping {
const int value;
- const char *icon;
+ const char* icon;
} psit_icon_mapping_t;
-static gbfile *psit_file_in;
-static gbfile *psit_file_out;
+static gbfile* psit_file_in;
+static gbfile* psit_file_out;
static short_handle mkshort_handle;
/* 2 = not written any tracks out
static char psit_current_token[256];
-char *snlen;
+char* snlen;
static
arglist_t psit_args[] = {
{ -1, NULL }
};
-static const char *
+static const char*
psit_find_desc_from_icon_number(const int icon)
{
- const psit_icon_mapping_t *i;
+ const psit_icon_mapping_t* i;
for (i = psit_icon_value_table; i->icon; i++) {
if (icon == i->value) {
}
static int
-psit_find_icon_number_from_desc(const char *desc)
+psit_find_icon_number_from_desc(const char* desc)
{
- const psit_icon_mapping_t *i;
+ const psit_icon_mapping_t* i;
int def_icon = 18;
if (!desc) {
}
static void
-psit_rd_init(const char *fname)
+psit_rd_init(const char* fname)
{
psit_file_in = gbfopen(fname, "r", MYNAME);
}
}
static void
-psit_wr_init(const char *fname)
+psit_wr_init(const char* fname)
{
psit_file_out = gbfopen(fname, "w", MYNAME);
}
* and write into buf.
*/
static void
-psit_getToken(gbfile *psit_file, char *buf, size_t sz, psit_tokenSep_type delimType)
+psit_getToken(gbfile* psit_file, char* buf, size_t sz, psit_tokenSep_type delimType)
{
int c = -1;
*
*/
static int
-psit_isKnownToken(char *buf)
+psit_isKnownToken(char* buf)
{
if (strcmp(buf, "Track:") == 0) {
return 0;
* MRCB
*/
static void
-psit_waypoint_r(gbfile *psit_file, waypoint **wpt)
+psit_waypoint_r(gbfile* psit_file, waypoint** wpt)
{
int garmin_icon_num;
- waypoint *thisWaypoint;
+ waypoint* thisWaypoint;
if (strlen(psit_current_token) > 0) {
thisWaypoint = waypt_new();
* MRCB
*/
static void
-psit_waypoint_w(gbfile *psit_file, const waypoint *wpt)
+psit_waypoint_w(gbfile* psit_file, const waypoint* wpt)
{
int icon;
- const char *ident;
- char *src = 0; /* BUGBUG Passed to mkshort */
+ const char* ident;
+ char* src = 0; /* BUGBUG Passed to mkshort */
gbfprintf(psit_file, "%11.6f,%11.6f,",
wpt->latitude,
}
static void
-psit_waypoint_w_wrapper(const waypoint *wpt)
+psit_waypoint_w_wrapper(const waypoint* wpt)
{
psit_waypoint_w(psit_file_out, wpt);
}
* MRCB
*/
static void
-psit_route_r(gbfile *psit_file, route_head **rte)
+psit_route_r(gbfile* psit_file, route_head** rte)
{
char rtename[256];
unsigned int rte_num;
int garmin_icon_num;
- route_head *rte_head;
+ route_head* rte_head;
unsigned int rte_count;
- waypoint *thisWaypoint;
+ waypoint* thisWaypoint;
psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), ltrimEOL);
* MRCB
*/
static void
-psit_routehdr_w(gbfile *psit_file, const route_head *rte)
+psit_routehdr_w(gbfile* psit_file, const route_head* rte)
{
char hdr[20];
unsigned int rte_datapoints;
- char *rname;
+ char* rname;
- waypoint *testwpt;
+ waypoint* testwpt;
time_t uniqueValue = 0;
int allWptNameLengths;
- queue *elem, *tmp;
+ queue* elem, *tmp;
/* total nodes (waypoints) this route */
rte_datapoints = 0;
allWptNameLengths = 0;
if (rte->waypoint_list.next) { /* this test doesn't do what I want i.e test if this is a valid route - treat as a placeholder for now */
- char *c;
+ char* c;
QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
- testwpt = (waypoint *)elem;
+ testwpt = (waypoint*)elem;
if (rte_datapoints == 0) {
uniqueValue = testwpt->GetCreationTime().toTime_t();
}
}
static void
-psit_routehdr_w_wrapper(const route_head *rte)
+psit_routehdr_w_wrapper(const route_head* rte)
{
psit_routehdr_w(psit_file_out, rte);
}
* MRCB
*/
static void
-psit_track_r(gbfile *psit_file, route_head **trk)
+psit_track_r(gbfile* psit_file, route_head** trk)
{
char tbuf[100];
char trkname[256];
struct tm tmTime;
time_t dateTime = 0;
- route_head *track_head = NULL;
+ route_head* track_head = NULL;
unsigned int trk_count;
- waypoint *thisWaypoint;
+ waypoint* thisWaypoint;
psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), ltrimEOL);
if (strlen(psit_current_token) == 0) {
* MRCB
*/
static void
-psit_trackhdr_w(gbfile *psit_file, const route_head *trk)
+psit_trackhdr_w(gbfile* psit_file, const route_head* trk)
{
char hdr[30];
unsigned int trk_datapoints;
- char *tname;
- waypoint *testwpt;
+ char* tname;
+ waypoint* testwpt;
time_t uniqueValue = 0;
- queue *elem, *tmp;
+ queue* elem, *tmp;
if (psit_track_state == 2) {
/* total nodes (waypoints) this track */
trk_datapoints = 0;
if (trk->waypoint_list.next) { /* this test doesn't do what I want i.e test if this is a valid track - treat as a placeholder for now */
- char *c;
+ char* c;
QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) {
if (trk_datapoints == 0) {
- testwpt = (waypoint *)elem;
+ testwpt = (waypoint*)elem;
uniqueValue = testwpt->GetCreationTime().toTime_t();
}
trk_datapoints++;
}
static void
-psit_trackhdr_w_wrapper(const route_head *trk)
+psit_trackhdr_w_wrapper(const route_head* trk)
{
psit_trackhdr_w(psit_file_out, trk);
}
* MRCB
*/
static void
-psit_trackdatapoint_w(gbfile *psit_file, const waypoint *wpt)
+psit_trackdatapoint_w(gbfile* psit_file, const waypoint* wpt)
{
time_t t = wpt->GetCreationTime().toTime_t();
- struct tm *tmTime = gmtime(&t);
+ struct tm* tmTime = gmtime(&t);
gbfprintf(psit_file, "%11.6f,%11.6f,",
wpt->latitude,
}
static void
-psit_trackdatapoint_w_wrapper(const waypoint *wpt)
+psit_trackdatapoint_w_wrapper(const waypoint* wpt)
{
psit_trackdatapoint_w(psit_file_out, wpt);
}
static void
psit_read(void)
{
- waypoint *wpt;
- route_head *rte;
- route_head *trk;
+ waypoint* wpt;
+ route_head* rte;
+ route_head* trk;
#ifdef DUMP_ICON_TABLE
printf("static icon_mapping_t icon_table[] = {\n");
}
static void
-psit_noop(const route_head *wp)
+psit_noop(const route_head* wp)
{
/* no-op */
}
#include "stddef.h"
void
-enqueue(queue *new_el, queue *old)
+enqueue(queue* new_el, queue* old)
{
new_el->next = old->next;
new_el->prev = old;
old->next = new_el;
}
-queue *
-dequeue(queue *element)
+queue*
+dequeue(queue* element)
{
- queue *prev = element->prev;
- queue *next = element->next;
+ queue* prev = element->prev;
+ queue* next = element->next;
next->prev = prev;
prev->next = next;
void
-sortqueue(queue *qh, int (*cmp)(const queue *, const queue *))
+sortqueue(queue* qh, int (*cmp)(const queue*, const queue*))
{
- queue *p, *q, *e, *tail, *oldhead, *list;
+ queue* p, *q, *e, *tail, *oldhead, *list;
int insize, nmerges, psize, qsize, i;
/*
#endif
static double pos_dist;
-static char *distopt = NULL;
-static char *latopt = NULL;
-static char *lonopt = NULL;
-static char *exclopt = NULL;
-static char *nosort = NULL;
-static char *maxctarg = NULL;
-static char *routename = NULL;
+static char* distopt = NULL;
+static char* latopt = NULL;
+static char* lonopt = NULL;
+static char* exclopt = NULL;
+static char* nosort = NULL;
+static char* maxctarg = NULL;
+static char* routename = NULL;
static int maxct;
-static waypoint * home_pos;
+static waypoint* home_pos;
typedef struct {
double distance;
}
static int
-dist_comp(const void * a, const void * b)
+dist_comp(const void* a, const void* b)
{
- const waypoint *x1 = *(waypoint **)a;
- const waypoint *x2 = *(waypoint **)b;
- extra_data *x1e = (extra_data *) x1->extra_data;
- extra_data *x2e = (extra_data *) x2->extra_data;
+ const waypoint* x1 = *(waypoint**)a;
+ const waypoint* x2 = *(waypoint**)b;
+ extra_data* x1e = (extra_data*) x1->extra_data;
+ extra_data* x2e = (extra_data*) x2->extra_data;
if (x1e->distance > x2e->distance) {
return 1;
void
radius_process(void)
{
- queue * elem, * tmp;
- waypoint * waypointp;
+ queue* elem, * tmp;
+ waypoint* waypointp;
double dist;
- waypoint ** comp;
+ waypoint** comp;
int i, wc;
queue temp_head;
- route_head *rte_head = NULL;
+ route_head* rte_head = NULL;
#if NEWQ
foreach(waypoint* waypointp, waypt_list) {
#else
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- waypointp = (waypoint *)elem;
+ waypointp = (waypoint*)elem;
#endif
dist = gc_distance(waypointp->latitude,
waypointp->longitude,
continue;
}
- extra_data *ed = (extra_data *) xcalloc(1, sizeof(*ed));
+ extra_data* ed = (extra_data*) xcalloc(1, sizeof(*ed));
ed->distance = dist;
waypointp->extra_data = ed;
}
wc = waypt_count();
QUEUE_INIT(&temp_head);
- comp = (waypoint **) xcalloc(wc, sizeof(*comp));
+ comp = (waypoint**) xcalloc(wc, sizeof(*comp));
i = 0;
*/
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- waypoint *wp = (waypoint *) elem;
+ waypoint* wp = (waypoint*) elem;
comp[i] = wp;
waypt_del(wp);
i++;
}
if (!nosort) {
- qsort(comp, wc, sizeof(waypoint *), dist_comp);
+ qsort(comp, wc, sizeof(waypoint*), dist_comp);
}
if (routename) {
* on through in the modified order.
*/
for (i = 0; i < wc; i++) {
- waypoint * wp = comp[i];
+ waypoint* wp = comp[i];
xfree(wp->extra_data);
wp->extra_data = NULL;
}
void
-radius_init(const char *args)
+radius_init(const char* args)
{
- char *fm;
+ char* fm;
pos_dist = 0;
maxct = 0;
}
- home_pos = (waypoint *) xcalloc(sizeof(*home_pos), 1);
+ home_pos = (waypoint*) xcalloc(sizeof(*home_pos), 1);
if (latopt) {
home_pos->latitude = atof(latopt);
#define MYNAME "random"
-static char *opt_points, *opt_seed;
+static char* opt_points, *opt_seed;
static arglist_t random_args[] = {
{
/* rand_str always returns a valid string with len >= 0 */
-static char *
-rand_str(const int maxlen, const char *fmt)
+static char*
+rand_str(const int maxlen, const char* fmt)
{
- char *res;
+ char* res;
int i, len;
len = rand_int(maxlen) + 1;
res[i] = c;
}
if (fmt) {
- char *tmp;
+ char* tmp;
xasprintf(&tmp, fmt, res);
xfree(res);
return tmp;
}
static void
-random_rd_init(const char *fname)
+random_rd_init(const char* fname)
{
}
#define RND(a) (rand_int(a) > 0)
int i, points;
- route_head *head;
- waypoint *prev = NULL;
+ route_head* head;
+ waypoint* prev = NULL;
time_t time = gpsbabel_time;
if (opt_seed) {
for (i = 0; i < points; i++) {
- waypoint *wpt;
- garmin_fs_t *gmsd;
+ waypoint* wpt;
+ garmin_fs_t* gmsd;
wpt = waypt_new();
gmsd = garmin_fs_alloc(-1);
- fs_chain_add(&wpt->fs, (format_specific_data *) gmsd);
+ fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
do {
wpt->shortname = rand_str(8, "Wpt_%s");
typedef unsigned long long guid_t;
-static inifile_t *fin;
-static gbfile *fout;
-static waypoint **waypt_table;
+static inifile_t* fin;
+static gbfile* fout;
+static waypoint** waypt_table;
static short_handle hshort_wpt, hshort_rte;
static int waypt_table_sz, waypt_table_ct;
static int rte_index, rte_wpt_index;
-static char *opt_location;
+static char* opt_location;
#define MYNAME "raymarine"
/* Bitmaps */
typedef struct {
- const char *name;
- const char *mps_name;
+ const char* name;
+ const char* mps_name;
} raymarine_symbol_mapping_t;
static raymarine_symbol_mapping_t raymarine_symbols[] = {
{
if (!descr.isNull()) {
- raymarine_symbol_mapping_t *a;
+ raymarine_symbol_mapping_t* a;
a = &raymarine_symbols[0];
/* ============================================= */
static void
-raymarine_rd_init(const char *fname)
+raymarine_rd_init(const char* fname)
{
fin = inifile_init(fname, MYNAME);
if (fin->unicode) {
static void
raymarine_read(void)
{
- waypoint *wpt;
+ waypoint* wpt;
unsigned int ix;
unsigned int rx;
for (ix = 0; ix < 0x3FFF; ix++) {
char sect[10];
- char *str, *name, *lat, *lon;
+ char* str, *name, *lat, *lon;
/* built section identifier */
snprintf(sect, sizeof(sect), "Wp%d", ix);
for (rx = 0; rx < 0x3FFF; rx++) {
char sect[10];
- char *name;
- route_head *rte;
+ char* name;
+ route_head* rte;
int wx;
snprintf(sect, sizeof(sect), "Rt%d", rx);
for (wx = 0; wx < 0x3FFF; wx++) {
char buff[32];
- char *str;
- waypoint * wpt;
+ char* str;
+ waypoint* wpt;
snprintf(buff, sizeof(buff), "Mk%d", wx);
str = inifile_readstr(fin, sect, buff);
/* make waypoint shortnames unique */
static char
-same_points(const waypoint *A, const waypoint *B)
+same_points(const waypoint* A, const waypoint* B)
{
return ( /* !!! We are case-sensitive !!! */
(strcmp(A->shortname, B->shortname) == 0) &&
}
static void
-register_waypt(const waypoint *ref, const char is_rtept)
+register_waypt(const waypoint* ref, const char is_rtept)
{
int i;
- waypoint *wpt = (waypoint *) ref;
+ waypoint* wpt = (waypoint*) ref;
for (i = 0; i < waypt_table_ct; i++) {
- waypoint *cmp = waypt_table[i];
+ waypoint* cmp = waypt_table[i];
if (same_points(wpt, cmp)) {
wpt->extra_data = cmp->extra_data;
}
}
- wpt->extra_data = (void *)mkshort(hshort_wpt, wpt->shortname);
+ wpt->extra_data = (void*)mkshort(hshort_wpt, wpt->shortname);
- waypt_table[waypt_table_ct] = (waypoint *)wpt;
+ waypt_table[waypt_table_ct] = (waypoint*)wpt;
waypt_table_ct++;
}
static void
-enum_waypt_cb(const waypoint *wpt)
+enum_waypt_cb(const waypoint* wpt)
{
- register_waypt((waypoint *) wpt, 0);
+ register_waypt((waypoint*) wpt, 0);
}
static void
-enum_rtept_cb(const waypoint *wpt)
+enum_rtept_cb(const waypoint* wpt)
{
- register_waypt((waypoint *) wpt, 1);
+ register_waypt((waypoint*) wpt, 1);
}
static int
-qsort_cb(const void *a, const void *b)
+qsort_cb(const void* a, const void* b)
{
- const waypoint *wa = *(waypoint **)a;
- const waypoint *wb = *(waypoint **)b;
+ const waypoint* wa = *(waypoint**)a;
+ const waypoint* wb = *(waypoint**)b;
return strcmp(wa->shortname, wb->shortname);
}
static void
-write_waypoint(gbfile *fout, const waypoint *wpt, const int waypt_no, const char *location)
+write_waypoint(gbfile* fout, const waypoint* wpt, const int waypt_no, const char* location)
{
- const char *notes;
- char *name;
+ const char* notes;
+ char* name;
double time;
notes = wpt->notes;
}
notes = csv_stringclean(notes, LINE_FEED);
time = wpt->creation_time.isValid() ? TIMET_TO_EXCEL(wpt->GetCreationTime().toTime_t()) : TIMET_TO_EXCEL(gpsbabel_time);
- name = (char *)wpt->extra_data;
+ name = (char*)wpt->extra_data;
gbfprintf(fout, "[Wp%d]" LINE_FEED
"Loc=%s" LINE_FEED
}
static void
-write_route_head_cb(const route_head *rte)
+write_route_head_cb(const route_head* rte)
{
char buff[32];
- char *name;
+ char* name;
name = rte->rte_name;
if ((name == NULL) || (*name == '\0')) {
}
static void
-write_route_wpt_cb(const waypoint *wpt)
+write_route_wpt_cb(const waypoint* wpt)
{
- static const char *items[] = {
+ static const char* items[] = {
"Cog",
"Eta",
"Length",
"PredictedTws"
};
- gbfprintf(fout, "Mk%d=%s" LINE_FEED, rte_wpt_index, (char *)wpt->extra_data);
- for (unsigned i = 0; i < sizeof(items) / sizeof(char *); i++) {
+ gbfprintf(fout, "Mk%d=%s" LINE_FEED, rte_wpt_index, (char*)wpt->extra_data);
+ for (unsigned i = 0; i < sizeof(items) / sizeof(char*); i++) {
gbfprintf(fout, "%s%d=%.15f" LINE_FEED, items[i], rte_wpt_index, 0.0);
}
}
static void
-enum_route_hdr_cb(const route_head *rte)
+enum_route_hdr_cb(const route_head* rte)
{
is_fatal(rte->rte_waypt_ct > 50,
MYNAME ": Routes with more than 50 points are not supported by Waymarine!");
}
static void
-raymarine_wr_init(const char *fname)
+raymarine_wr_init(const char* fname)
{
fout = gbfopen(fname, "wb", MYNAME);
raymarine_write(void)
{
int i;
- waypoint *wpt;
+ waypoint* wpt;
waypt_table_sz = 0;
waypt_table_ct = 0;
/* write out waypoint summary */
for (i = 0; i < waypt_table_ct; i++) {
- waypoint *wpt = waypt_table[i];
+ waypoint* wpt = waypt_table[i];
write_waypoint(fout, wpt, i, opt_location);
}
static void reverse_route_wpt(const waypoint* waypointp)
{
- /* Cast away const-ness */
- waypoint* wpp = (waypoint *) waypointp;
+ /* Cast away const-ness */
+ waypoint* wpp = (waypoint*) waypointp;
- int curr_new_trkseg;
+ int curr_new_trkseg;
- curr_new_trkseg = waypointp->wpt_flags.new_trkseg;
- wpp->wpt_flags.new_trkseg = prev_new_trkseg;
- prev_new_trkseg = curr_new_trkseg;
+ curr_new_trkseg = waypointp->wpt_flags.new_trkseg;
+ wpp->wpt_flags.new_trkseg = prev_new_trkseg;
+ prev_new_trkseg = curr_new_trkseg;
}
void
-reverse_route_head(const route_head *rte)
+reverse_route_head(const route_head* rte)
{
route_reverse(rte);
prev_new_trkseg = 1;
}
void
-reverse_route_init(const char *args)
+reverse_route_init(const char* args)
{
switch (global_opts.objective) {
case rtedata:
*/
static const struct {
- const char *cn;
+ const char* cn;
unsigned char r;
unsigned char g;
unsigned char b;
*/
static int HexDigit(char hex)
{
- const char *Digits = "0123456789ABCDEF";
- const char *digits = "0123456789abcdef";
- const char *ofs = strchr(digits, hex);
+ const char* Digits = "0123456789ABCDEF";
+ const char* digits = "0123456789abcdef";
+ const char* ofs = strchr(digits, hex);
if (ofs) {
return ofs-digits;
}
*/
int
-color_to_bbggrr(const char *opt_color)
+color_to_bbggrr(const char* opt_color)
{
int color_num;
unsigned int i;
- char *ep;
+ char* ep;
color_num = strtol(opt_color, &ep, 10);
return trk_head_ct; /* total # of tracks */
}
-route_head *
+route_head*
route_head_alloc(void)
{
route_head* rte_head = new route_head;
}
static void
-any_route_free(route_head *rte)
+any_route_free(route_head* rte)
{
if (rte->rte_name) {
xfree(rte->rte_name);
static void
-any_route_add_head(route_head *rte, queue *head)
+any_route_add_head(route_head* rte, queue* head)
{
ENQUEUE_TAIL(head, &rte->Q);
}
static void
-any_route_del_head(route_head *rte)
+any_route_del_head(route_head* rte)
{
dequeue(&rte->Q);
any_route_free(rte);
}
void
-route_add_head(route_head *rte)
+route_add_head(route_head* rte)
{
any_route_add_head(rte, &my_route_head);
rte_head_ct++;
}
void
-route_del_head(route_head *rte)
+route_del_head(route_head* rte)
{
any_route_del_head(rte);
rte_head_ct--;
}
void
-track_add_head(route_head *rte)
+track_add_head(route_head* rte)
{
any_route_add_head(rte, &my_track_head);
trk_head_ct++;
}
void
-track_del_head(route_head *rte)
+track_del_head(route_head* rte)
{
any_route_del_head(rte);
trk_head_ct--;
}
void
-track_insert_head(route_head *rte, route_head *predecessor)
+track_insert_head(route_head* rte, route_head* predecessor)
{
ENQUEUE_AFTER(&predecessor->Q, &rte->Q);
trk_head_ct++;
}
static
-route_head *
-common_route_by_name(queue *routes, const char *name)
+route_head*
+common_route_by_name(queue* routes, const char* name)
{
- queue *elem, *tmp;
- route_head *rte;
+ queue* elem, *tmp;
+ route_head* rte;
QUEUE_FOR_EACH(routes, elem, tmp) {
- rte = (route_head *) elem;
+ rte = (route_head*) elem;
if (0 == strcmp(rte->rte_name, name)) {
return rte;
}
return NULL;
}
-route_head *
-route_find_route_by_name(const char *name)
+route_head*
+route_find_route_by_name(const char* name)
{
return common_route_by_name(&my_route_head, name);
}
-route_head *
-route_find_track_by_name(const char *name)
+route_head*
+route_find_track_by_name(const char* name)
{
return common_route_by_name(&my_track_head, name);
}
static void
-any_route_add_wpt(route_head *rte, waypoint *wpt, int *ct, int synth)
+any_route_add_wpt(route_head* rte, waypoint* wpt, int* ct, int synth)
{
ENQUEUE_TAIL(&rte->waypoint_list, &wpt->Q);
rte->rte_waypt_ct++; /* waypoints in this route */
}
void
-route_add_wpt(route_head *rte, waypoint *wpt)
+route_add_wpt(route_head* rte, waypoint* wpt)
{
// First point in a route is always a new segment.
// This improves compatibility when reading from
}
void
-track_add_wpt(route_head *rte, waypoint *wpt)
+track_add_wpt(route_head* rte, waypoint* wpt)
{
// First point in a track is always a new segment.
// This improves compatibility when reading from
any_route_add_wpt(rte, wpt, &trk_waypts, 0);
}
-waypoint *
-route_find_waypt_by_name(route_head *rh, const char *name)
+waypoint*
+route_find_waypt_by_name(route_head* rh, const char* name)
{
- queue *elem, *tmp;
+ queue* elem, *tmp;
QUEUE_FOR_EACH(&rh->waypoint_list, elem, tmp) {
- waypoint *waypointp = (waypoint *) elem;
+ waypoint* waypointp = (waypoint*) elem;
if (0 == strcmp(waypointp->shortname, name)) {
return waypointp;
}
}
static void
-any_route_del_wpt(route_head *rte, waypoint *wpt, int *ct)
+any_route_del_wpt(route_head* rte, waypoint* wpt, int* ct)
{
if (wpt->wpt_flags.new_trkseg && wpt != (waypoint*)QUEUE_LAST(&rte->waypoint_list)) {
waypoint* wpt_next = (waypoint*)QUEUE_NEXT(&wpt->Q);
}
void
-route_del_wpt(route_head *rte, waypoint *wpt)
+route_del_wpt(route_head* rte, waypoint* wpt)
{
any_route_del_wpt(rte, wpt, &rte_waypts);
}
void
-track_del_wpt(route_head *rte, waypoint *wpt)
+track_del_wpt(route_head* rte, waypoint* wpt)
{
any_route_del_wpt(rte, wpt, &trk_waypts);
}
void
-route_disp(const route_head *rh, waypt_cb cb)
+route_disp(const route_head* rh, waypt_cb cb)
{
- queue *elem, *tmp;
+ queue* elem, *tmp;
if (!cb) {
return;
}
QUEUE_FOR_EACH(&rh->waypoint_list, elem, tmp) {
- waypoint *waypointp;
- waypointp = (waypoint *) elem;
+ waypoint* waypointp;
+ waypointp = (waypoint*) elem;
(*cb)(waypointp);
}
}
void
-route_reverse(const route_head *rte_hd)
+route_reverse(const route_head* rte_hd)
{
/* Cast away const-ness */
- route_head *rh = (route_head *) rte_hd;
- queue *elem, *tmp;
+ route_head* rh = (route_head*) rte_hd;
+ queue* elem, *tmp;
QUEUE_FOR_EACH(&rh->waypoint_list, elem, tmp) {
ENQUEUE_HEAD(&rh->waypoint_list, dequeue(elem));
}
}
static void
-common_disp_all(queue *qh, route_hdr rh, route_trl rt, waypt_cb wc)
+common_disp_all(queue* qh, route_hdr rh, route_trl rt, waypt_cb wc)
{
- queue *elem, *tmp;
+ queue* elem, *tmp;
QUEUE_FOR_EACH(qh, elem, tmp) {
- const route_head *rhp;
- rhp = (route_head *) elem;
+ const route_head* rhp;
+ rhp = (route_head*) elem;
if (rh) {
(*rh)(rhp);
}
}
static void
-common_disp_session(const session_t *se, queue *qh, route_hdr rh, route_trl rt, waypt_cb wc)
+common_disp_session(const session_t* se, queue* qh, route_hdr rh, route_trl rt, waypt_cb wc)
{
- queue *elem, *tmp;
+ queue* elem, *tmp;
QUEUE_FOR_EACH(qh, elem, tmp) {
- const route_head *rhp;
- rhp = (route_head *) elem;
+ const route_head* rhp;
+ rhp = (route_head*) elem;
if (rhp->session == se) {
if (rh) {
(*rh)(rhp);
}
void
-route_disp_session(const session_t *se, route_hdr rh, route_trl rt, waypt_cb wc)
+route_disp_session(const session_t* se, route_hdr rh, route_trl rt, waypt_cb wc)
{
common_disp_session(se, &my_route_head, rh, rt, wc);
}
}
void
-track_disp_session(const session_t *se, route_hdr rh, route_trl rt, waypt_cb wc)
+track_disp_session(const session_t* se, route_hdr rh, route_trl rt, waypt_cb wc)
{
common_disp_session(se, &my_track_head, rh, rt, wc);
}
static void
-route_flush_q(queue *head)
+route_flush_q(queue* head)
{
- queue *elem, *tmp;
- queue *q;
+ queue* elem, *tmp;
+ queue* q;
QUEUE_FOR_EACH(head, elem, tmp) {
q = dequeue(elem);
- any_route_free((route_head *) q);
+ any_route_free((route_head*) q);
}
}
}
void
-route_flush(queue *head)
+route_flush(queue* head)
{
- queue *elem, *tmp;
- queue *q;
+ queue* elem, *tmp;
+ queue* q;
QUEUE_FOR_EACH(head, elem, tmp) {
q = dequeue(elem);
- any_route_free((route_head *)q);
+ any_route_free((route_head*)q);
}
}
void
-route_copy(int *dst_count, int *dst_wpt_count, queue **dst, queue *src)
+route_copy(int* dst_count, int* dst_wpt_count, queue** dst, queue* src)
{
- queue *elem, *tmp, *elem2, *tmp2;
- route_head *rte_new;
+ queue* elem, *tmp, *elem2, *tmp2;
+ route_head* rte_new;
int junk;
if (!dst_wpt_count) {
dst_wpt_count = &junk;
}
if (!*dst) {
- *dst = (queue *)xcalloc(1, sizeof(queue));
+ *dst = (queue*)xcalloc(1, sizeof(queue));
QUEUE_INIT(*dst);
*dst_count = 0;
*dst_wpt_count = 0;
}
QUEUE_FOR_EACH(src, elem, tmp) {
- route_head *rte_old = (route_head *)elem;
+ route_head* rte_old = (route_head*)elem;
rte_new = route_head_alloc();
rte_new->rte_name = xstrdup(rte_old->rte_name);
rte_new->rte_num = rte_old->rte_num;
any_route_add_head(rte_new, *dst);
QUEUE_FOR_EACH(&rte_old->waypoint_list, elem2, tmp2) {
- any_route_add_wpt(rte_new, waypt_dupe((waypoint *)elem2), dst_wpt_count, 0);
+ any_route_add_wpt(rte_new, waypt_dupe((waypoint*)elem2), dst_wpt_count, 0);
}
(*dst_count)++;
}
}
void
-route_append(queue *src)
+route_append(queue* src)
{
- queue *dst = &my_route_head;
+ queue* dst = &my_route_head;
route_copy(&rte_head_ct, &rte_waypts, &dst, src);
}
void
-track_append(queue *src)
+track_append(queue* src)
{
- queue *dst = &my_track_head;
+ queue* dst = &my_track_head;
route_copy(&trk_head_ct, &trk_waypts, &dst, src);
}
void
-route_backup(signed int *count, queue **head_bak)
+route_backup(signed int* count, queue** head_bak)
{
route_copy(count, NULL, head_bak, &my_route_head);
}
static void
-route_restore_hdr(const route_head *rte)
+route_restore_hdr(const route_head* rte)
{
rte_head_ct++;
}
static void
-track_restore_hdr(const route_head *trk)
+track_restore_hdr(const route_head* trk)
{
trk_head_ct++;
}
static void
-route_restore_tlr(const route_head *rte)
+route_restore_tlr(const route_head* rte)
{
}
static void
-route_restore_wpt(const waypoint *wpt)
+route_restore_wpt(const waypoint* wpt)
{
rte_waypts++;
}
static void
-track_restore_wpt(const waypoint *wpt)
+track_restore_wpt(const waypoint* wpt)
{
trk_waypts++;
}
}
void
-route_restore(queue *head_bak)
+route_restore(queue* head_bak)
{
if (head_bak == NULL) {
return;
}
void
-track_backup(signed int *count, queue **head_bak)
+track_backup(signed int* count, queue** head_bak)
{
route_copy(count, NULL, head_bak, &my_track_head);
}
void
-track_restore(queue *head_bak)
+track_restore(queue* head_bak)
{
if (head_bak == NULL) {
return;
void
routes_to_tracks(void)
{
- queue *elem, *tmp;
+ queue* elem, *tmp;
QUEUE_FOR_EACH(&my_route_head, elem, tmp) {
- route_head *trk = (route_head *) elem;
+ route_head* trk = (route_head*) elem;
dequeue(&trk->Q);
ENQUEUE_TAIL(&my_track_head, &trk->Q);
}
void
tracks_to_routes(void)
{
- queue *elem, *tmp;
+ queue* elem, *tmp;
QUEUE_FOR_EACH(&my_track_head, elem, tmp) {
- route_head *trk = (route_head *) elem;
+ route_head* trk = (route_head*) elem;
dequeue(&trk->Q);
ENQUEUE_TAIL(&my_route_head, &trk->Q);
}
* If trkdatap is non-null upon entry, a pointer to an allocated collection
* (hopefully interesting) statistics about the track will be placed there.
*/
-void track_recompute(const route_head *trk, computed_trkdata **trkdatap)
+void track_recompute(const route_head* trk, computed_trkdata** trkdatap)
{
waypoint first;
- waypoint *thisw;
- waypoint *prev = &first;
- queue *elem, *tmp;
+ waypoint* thisw;
+ waypoint* prev = &first;
+ queue* elem, *tmp;
int tkpt = 0;
int pts_hrt = 0;
double tot_hrt = 0.0;
int pts_cad = 0;
double tot_cad = 0.0;
char tkptname[100];
- computed_trkdata *tdata = (computed_trkdata *)xcalloc(1, sizeof(computed_trkdata));
+ computed_trkdata* tdata = (computed_trkdata*)xcalloc(1, sizeof(computed_trkdata));
if (trkdatap) {
*trkdatap = tdata;
tdata->min_alt = -unknown_alt;
tdata->max_alt = unknown_alt;
- QUEUE_FOR_EACH((queue *)&trk->waypoint_list, elem, tmp) {
+ QUEUE_FOR_EACH((queue*)&trk->waypoint_list, elem, tmp) {
double tlat, tlon, plat, plon, dist;
- thisw = (waypoint *)elem;
+ thisw = (waypoint*)elem;
/*
* gcdist and heading want radians, not degrees.
prev->GetCreationTime().isValid() &&
thisw->GetCreationTime() > prev->GetCreationTime()) {
double timed =
- prev->GetCreationTime().msecsTo(thisw->GetCreationTime()) / 1000.0;
+ prev->GetCreationTime().msecsTo(thisw->GetCreationTime()) / 1000.0;
WAYPT_SET(thisw, speed, dist / timed);
}
}
#include "defs.h"
#include "grtcirc.h"
-gbfile *infile;
+gbfile* infile;
-char *turns_important = NULL;
-char *turns_only = NULL;
-char *controls = NULL;
-char *split = NULL;
-char *timesynth = NULL;
+char* turns_important = NULL;
+char* turns_only = NULL;
+char* controls = NULL;
+char* split = NULL;
+char* timesynth = NULL;
int control = 0;
#define ReadShort(f) gbfgetint16(f)
#define ReadLong(f) gbfgetint32(f)
-unsigned char *
-ReadRecord(gbfile *f, gbsize_t size)
+unsigned char*
+ReadRecord(gbfile* f, gbsize_t size)
{
- unsigned char *result = (unsigned char *) xmalloc(size);
+ unsigned char* result = (unsigned char*) xmalloc(size);
(void)gbfread(result, size, 1, f);
return result;
}
void
-Skip(gbfile * f, gbsize_t distance)
+Skip(gbfile* f, gbsize_t distance)
{
gbfseek(f, distance, SEEK_CUR);
}
static void
-rd_init(const char *fname)
+rd_init(const char* fname)
{
infile = gbfopen(fname, "rb", MYNAME);
if (split && (turns_important || turns_only)) {
uint32_t outercount;
uint32_t recsize;
uint16_t stringlen;
- unsigned char *record;
+ unsigned char* record;
static int serial = 0;
struct ll {
int32_t lat;
int32_t lon;
} *latlon;
uint16_t coordcount;
- route_head *track_head = NULL;
- route_head *old_track_head = NULL;
- waypoint *wpt_tmp;
- char *routename = NULL;
+ route_head* track_head = NULL;
+ route_head* old_track_head = NULL;
+ waypoint* wpt_tmp;
+ char* routename = NULL;
double seglen = 0.0;
int32_t starttime = 0;
int32_t transittime = 0;
*/
record = ReadRecord(infile, recsize);
- stringlen = le_read16((uint16_t *)(record + 0x1a));
+ stringlen = le_read16((uint16_t*)(record + 0x1a));
if (stringlen) {
- routename = (char *)xmalloc(stringlen + 1);
+ routename = (char*)xmalloc(stringlen + 1);
routename[stringlen] = '\0';
memcpy(routename, record+0x1c, stringlen);
}
double lon;
record = ReadRecord(infile, recsize);
- latlon = (struct ll *)(record);
+ latlon = (struct ll*)(record);
/* These records are backwards for some reason */
lat = (0x80000000UL -
wpt_tmp->shortname = (char*) xmalloc(addrlen+1);
wpt_tmp->shortname[addrlen]='\0';
- wpt_tmp->notes = (char *) xmalloc(cmtlen+1);
+ wpt_tmp->notes = (char*) xmalloc(cmtlen+1);
wpt_tmp->notes[cmtlen] = '\0';
memcpy(wpt_tmp->notes,
record+obase+4+addrlen,
ReadShort(infile);
recsize = ReadLong(infile);
record = ReadRecord(infile, recsize);
- stringlen = le_read16((uint16_t *)record);
+ stringlen = le_read16((uint16_t*)record);
if (split && stringlen) {
if (track_head->rte_waypt_ct) {
old_track_head = track_head;
} // end if
if (!track_head->rte_name) {
track_head->rte_name =
- (char *)xmalloc(stringlen+1);
+ (char*)xmalloc(stringlen+1);
strncpy(track_head->rte_name,
- (const char *) record+2, stringlen);
+ (const char*) record+2, stringlen);
track_head->rte_name[stringlen] = '\0';
}
}
if (timesynth) {
seglen = le_read_double(
record + 2 + stringlen + 0x08);
- starttime = le_read32((uint32_t *)
+ starttime = le_read32((uint32_t*)
(record + 2 + stringlen + 0x30));
- transittime = le_read32((uint32_t *)
+ transittime = le_read32((uint32_t*)
(record + 2 + stringlen + 0x10));
seglen /= 5280*12*2.54/100000; /* to miles */
}
- coordcount = le_read16((uint16_t *)
+ coordcount = le_read16((uint16_t*)
(record + 2 + stringlen + 0x3c));
- latlon = (struct ll *)(record + 2 + stringlen + 0x3c + 2);
+ latlon = (struct ll*)(record + 2 + stringlen + 0x3c + 2);
count--;
if (count) {
coordcount--;
wpt_tmp->latitude = lat;
wpt_tmp->longitude = -lon;
if (stringlen && ((coordcount>1) || count)) {
- wpt_tmp->shortname = (char *) xmalloc(stringlen+1);
+ wpt_tmp->shortname = (char*) xmalloc(stringlen+1);
wpt_tmp->shortname[stringlen] = '\0';
memcpy(wpt_tmp->shortname,
- ((char *)record)+2,
+ ((char*)record)+2,
stringlen);
} else {
- wpt_tmp->shortname = (char *) xmalloc(7);
+ wpt_tmp->shortname = (char*) xmalloc(7);
sprintf(wpt_tmp->shortname, "\\%5.5x",
serial++);
}
}
static void
-wr_init(const char *fname)
+wr_init(const char* fname)
{
fatal(MYNAME ":Not enough information is known about this format to write it.\n");
}
#define MYNAME "sbn"
-static gbfile *file_handle = NULL;
+static gbfile* file_handle = NULL;
static
arglist_t sbn_args[] = {
* instead of serial, and integers are read in big endian order.
*/
static size_t
-read_packet(int *type, void *payload, size_t max_len)
+read_packet(int* type, void* payload, size_t max_len)
{
size_t size, data_size;
unsigned char start[4];
unsigned int checksum_exp, checksum_act;
- unsigned char *data;
+ unsigned char* data;
if (gbfread(start, sizeof(start), 1, file_handle) != 1) {
if (gbfeof(file_handle)) {
data_size = size + 4;
/* data_size can be up to about 64k */
- data = (unsigned char *) xmalloc(data_size);
+ data = (unsigned char*) xmalloc(data_size);
if (gbfread(data, data_size, 1, file_handle) != 1) {
fatal(MYNAME ": Format error: could not read %d bytes.\n",
#ifdef LOCOSYS_PARSE_FILE_ID
static size_t
-hdrcpy(char *dest, const char *src, size_t max_len)
+hdrcpy(char* dest, const char* src, size_t max_len)
{
size_t i;
#endif /* LOCOSYS_PARSE_FILE_ID */
int
-locosys_decode_file_id(char *header, size_t len)
+locosys_decode_file_id(char* header, size_t len)
{
#ifdef LOCOSYS_PARSE_FILE_ID
/*
char serial_num[INFO_SERIAL_NUM_LEN + 1];
char log_rate[INFO_LOG_RATE_LEN + 1];
char version[INFO_VERSION_LEN + 1];
- char *p = header;
+ char* p = header;
p += hdrcpy(username, p, INFO_USERNAME_LEN);
p += hdrcpy(serial_num, p, INFO_SERIAL_NUM_LEN);
}
static void
-read_sbn_header(route_head *track)
+read_sbn_header(route_head* track)
{
char header[QRY_INFORMATION_LEN];
size_t len;
}
static int
-is_sbn_valid(const unsigned char *buffer)
+is_sbn_valid(const unsigned char* buffer)
{
/* valid navigation (any bit set implies navigation solution is not
* optimal) */
}
static fix_type
-decode_sbn_mode(const unsigned char *mode)
+decode_sbn_mode(const unsigned char* mode)
{
static const fix_type fixes[8] = {
fix_none, /* 000 No Nav */
}
static void
-decode_sbn_datetime(const unsigned char *buffer, waypoint *waypt)
+decode_sbn_datetime(const unsigned char* buffer, waypoint* waypt)
{
struct tm tm;
int ms = be_readu16(buffer + 6);
}
static void
-decode_sbn_position(const unsigned char *buffer, waypoint *waypt)
+decode_sbn_position(const unsigned char* buffer, waypoint* waypt)
{
waypt->latitude = be_read32(buffer + 0) * 0.0000001;
waypt->longitude = be_read32(buffer + 4) * 0.0000001;
waypt->altitude = be_read32(buffer + 12) * 0.01;
}
-static waypoint *
-decode_sbn_record(unsigned char *buffer)
+static waypoint*
+decode_sbn_record(unsigned char* buffer)
{
- waypoint *waypt = NULL;
+ waypoint* waypt = NULL;
waypt = waypt_new();
if (is_sbn_valid(buffer)) {
}
static void
-add_logpoints(route_head *track)
+add_logpoints(route_head* track)
{
unsigned char buffer[SBN_RECORD_LEN];
int type = 0;
/**********************************************************************/
static void
-sbn_rd_init(const char *fname)
+sbn_rd_init(const char* fname)
{
file_handle = gbfopen(fname, "r", MYNAME);
}
sbn_read(void)
{
if (global_opts.masked_objective & TRKDATAMASK) {
- route_head *track;
+ route_head* track;
track = route_head_alloc();
track_add_head(track);
#define MYNAME "sbp"
-static gbfile *file_handle = NULL;
+static gbfile* file_handle = NULL;
static
arglist_t sbp_args[] = {
*******************************************************************************/
static void
-sbp_rd_init(const char *fname)
+sbp_rd_init(const char* fname)
{
file_handle = gbfopen(fname, "r", MYNAME);
}
}
static void
-read_sbp_header(route_head *track)
+read_sbp_header(route_head* track)
{
/*
* A complete SBP file contains 64 bytes header,
}
}
-static waypoint *
+static waypoint*
read_logpoint(void)
{
unsigned char buffer[SBP_RECORD_LEN];
sbp_read(void)
{
if (global_opts.masked_objective & TRKDATAMASK) {
- waypoint *logpoint;
- route_head *track;
+ waypoint* logpoint;
+ route_head* track;
track = route_head_alloc();
track_add_head(track);
static queue session_list;
static int session_ct;
-static void session_free(session_t *s);
+static void session_free(session_t* s);
void
session_init(void)
void
session_exit(void)
{
- queue *elem, *tmp;
+ queue* elem, *tmp;
QUEUE_FOR_EACH(&session_list, elem, tmp) {
- session_t *s = (session_t *)elem;
+ session_t* s = (session_t*)elem;
dequeue(&s->Q);
session_free(s);
}
}
void
-start_session(const char *name, const char *filename)
+start_session(const char* name, const char* filename)
{
- session_t *s;
+ session_t* s;
if (session_ct == 0) {
QUEUE_INIT(&session_list);
s->filename = xstrdup(filename);
}
-session_t *
+session_t*
curr_session(void)
{
- return (session_t *) session_list.prev;
+ return (session_t*) session_list.prev;
}
/* in work
/* non public functions */
static void
-session_free(session_t *s)
+session_free(session_t* s)
{
- queue *elem, *tmp;
+ queue* elem, *tmp;
QUEUE_FOR_EACH(&s->category_list, elem, tmp) {
- category_t *c = (category_t *) elem;
+ category_t* c = (category_t*) elem;
dequeue(&c->Q);
xfree(c);
}
#define MYNAME "shape"
static unsigned poly_count;
-static double *polybufx;
-static double *polybufy;
-static double *polybufz;
-static const char *ofname;
+static double* polybufx;
+static double* polybufy;
+static double* polybufz;
+static const char* ofname;
static int nameidx;
static int urlidx;
-static char *opt_name = NULL;
-static char *opt_url = NULL;
+static char* opt_name = NULL;
+static char* opt_url = NULL;
static
arglist_t shp_args[] = {
};
static void
-my_rd_init(const char *fname)
+my_rd_init(const char* fname)
{
ihandle = SHPOpen(fname, "rb");
if (ihandle == NULL) {
int nFields = 0;
int i = 0;
char name[12];
- char *txt = xstrdup(" Database fields\n");
+ char* txt = xstrdup(" Database fields\n");
nFields = DBFGetFieldCount(ihandledb);
for (i = 0; i < nFields; i++) {
char txtName[50];
my_read(void)
{
int npts;
- const char *etype = "unknown";
+ const char* etype = "unknown";
SHPGetInfo(ihandle, &npts, NULL, NULL, NULL);
while (npts) {
- SHPObject *shp;
- waypoint *wpt;
- const char *name = "";
- const char *url;
- char *tmpName = NULL;
- char *tmpIndex = opt_name;
+ SHPObject* shp;
+ waypoint* wpt;
+ const char* name = "";
+ const char* url;
+ char* tmpName = NULL;
+ char* tmpIndex = opt_name;
shp = SHPReadObject(ihandle, npts-1);
if (nameidx >0) {
tmpName = xstrdup("");
tmpIndex = opt_name;
while (tmpIndex) {
- char *tmp2 = tmpIndex;
+ char* tmp2 = tmpIndex;
tmpIndex = strchr(tmpIndex,'+');
if (tmpIndex) {
*tmpIndex = '\0';
switch (shp->nSHPType) {
case SHPT_ARC: {
int j;
- route_head *routehead = route_head_alloc();
+ route_head* routehead = route_head_alloc();
routehead->rte_name = xstrdup(name);
route_add_head(routehead);
for (j = 0; j < shp->nVertices; j++) {
}
void
-my_wr_init(const char *fname)
+my_wr_init(const char* fname)
{
ofname = fname;
}
}
void
-my_write_wpt(const waypoint *wpt)
+my_write_wpt(const waypoint* wpt)
{
- SHPObject *shpobject;
+ SHPObject* shpobject;
shpobject = SHPCreateSimpleObject(SHPT_POINT, 1,
- (double *)(void *)&wpt->longitude,
- (double *)(void *)&wpt->latitude,
- (double *)(void *)&wpt->altitude);
+ (double*)(void*)&wpt->longitude,
+ (double*)(void*)&wpt->latitude,
+ (double*)(void*)&wpt->altitude);
SHPWriteObject(ohandle, -1, shpobject);
SHPDestroyObject(shpobject);
}
void
-poly_init(const route_head *h)
+poly_init(const route_head* h)
{
int ct = track_waypt_count();
polybufx = (double*) xcalloc(ct, sizeof(double));
void
-poly_point(const waypoint *wpt)
+poly_point(const waypoint* wpt)
{
polybufx[poly_count] = wpt->longitude;
polybufy[poly_count] = wpt->latitude;
}
void
-poly_deinit(const route_head *h)
+poly_deinit(const route_head* h)
{
- SHPObject *shpobject;
+ SHPObject* shpobject;
shpobject = SHPCreateSimpleObject(SHPT_ARC, track_waypt_count(),
polybufx, polybufy, polybufz);
SHPWriteObject(ohandle, -1, shpobject);
const QString kVowels("aeiou");
static struct replacements {
- const char *orig;
- const char *replacement;
+ const char* orig;
+ const char* replacement;
} replacements[] = {
{"zero", "0"},
{"one", "1"},
QString Shortname::DeleteLastVowel(int start, const QString& s,
- bool& replaced) {
- QString out = s;
- replaced = false;
+ bool& replaced)
+{
+ QString out = s;
+ replaced = false;
#if 1
for (int i = s.length() -1; i > start; i--) {
QChar c = s[i];
// Preserve vowel if first of a word.
if (i > 0) {
- if (s[i-1].isSpace())
+ if (s[i-1].isSpace()) {
continue;
+ }
}
if (kVowels.contains(c, Qt::CaseInsensitive)) {
out = out.remove(i, 1);
return out;
}
-QString Shortname::Replace(const QString& in) {
+QString Shortname::Replace(const QString& in)
+{
QString out = in;
- struct replacements *r;
+ struct replacements* r;
for (r = replacements; r->orig; r++) {
// while(int i = out.indexOf(r->orig, 1) > 2) {
- int i = out.indexOf(r->orig, 1);
- if(i > 1) {
-fprintf(stderr, "%d\n", i);
+ int i = out.indexOf(r->orig, 1);
+ if (i > 1) {
+ fprintf(stderr, "%d\n", i);
if (out[i-1] == ' ') {
out = out.replace(i, strlen(r->orig), r->replacement);
}
return out;
}
-QString Shortname::Shorten(const QString& in) {
+QString Shortname::Shorten(const QString& in)
+{
// Eliminate leading and trailing whitespace and replace internal
// whitespace sequences (tabs, multiple spaces, etc.) with a single space.
QString out = in.simplified();
while (name_list_.contains(t)) {
printf("Conflict %d\n", conflict_counter_);
QString trailer = QString(".%1").arg(conflict_counter_);
-fprintf(stderr, "Trailer: %s\n", qPrintable(trailer));
+ fprintf(stderr, "Trailer: %s\n", qPrintable(trailer));
t.truncate(target_len_ - trailer.length());
-fprintf(stderr, "Truncate: %s\n", qPrintable(t));
+ fprintf(stderr, "Truncate: %s\n", qPrintable(t));
t = t.append(trailer);
conflict_counter_++;
}
out = t;
name_list_.insert(out);
}
- fprintf(stderr, "Returning %s\n", qPrintable(out));
+ fprintf(stderr, "Returning %s\n", qPrintable(out));
assert(out.length() <= target_len_);
return out;
}
#if 1
-char *foo[] = {
-"VwthPst# 3700.706N 08627.588W 0000000m View the Past #2 ",
-"PilotRoc 3655.270N 08717.173W 0000000m Pilot Rock ",
-"MrCycsNg 3652.407N 08728.890W 0000000m Mr. Cayces Neighborhood ",
-"SOLDIER 3640.691N 08726.660W 0000000m SOLDIER’S TRIBUTE ",
-"ZOOMZOOM 3636.659N 08721.793W 0000000m ZOOM ZOOM ZOOM by Feros Family",
-"SOCLOSEB 3636.494N 08722.086W 0000000m SO CLOSE BUT YET by Kyle of Fe",
-"InSrchfS 3636.363N 08636.363W 0000000m In Search of Steam by BigHank ",
-"RdBlngSp 3632.119N 08550.956W 0000000m Red Boiling Springs by Firedog",
-"HelngWtr 3631.729N 08550.481W 0000000m Healing Waters by FiredogPotte",
-"AHHtheVi 3629.020N 08533.891W 0000000m ogPotter ",
-"LstCrkCc 3628.167N 08801.656W 0000000m Lost Creek Cache by Paul Kathy",
-"DlvrncTr 3626.412N 08729.249W 0000000m Deliverance Train by Team Skay",
-"FrQrtrRn 3438.502N 08646.926W 0000000m Four Quarter Rendezvous by Zay",
-"Jstlttlc 3620.647N 08814.298W 0000000m Just a little cache by Paul Ka",
-"BrryPtch 3618.786N 08616.344W 0000000m Berry Patch Cache by White Dog",
-"AStrllDw 3342.752N 08630.829W 0000000m A Stroll Down Memory Lane by t",
-"QunfTnns 3606.413N 08651.962W 0000000m Queen of Tennessee by A182pilo",
-"GoneFish 3618.199N 08655.171W 0000000m Gone Fishin' by White Dog Pack",
-"GrnwysFn 3610.942N 08642.061W 0000000m Greenways Fence by Ukulele And",
-"AStnsThr 3611.240N 08638.324W 0000000m A Stone's Throw by Murrcat & S",
-"Nashvlls 3617.112N 08642.359W 0000000m Nashville's Zoo by White Dog P",
-"BltzMcr4 3517.127N 08622.211W 0000000m Blitz Micro Number 4 ",
-"NkdnthWn 3437.145N 08651.693W 0000000m Naked in the Wind by Zaybex ",
-"ANcPlctR 3603.389N 08654.418W 0000000m A Nice Place to Rest by JoGPS ",
-"welcomtT 3638.155N 08720.130W 0000000m welcome to TN by Raf of the se",
-"welcomtK 3638.956N 08721.011W 0000000m welcome to KY by raf of the se",
-"BltzMcr5 3506.191N 08634.277W 0000000m Blitz Micro Number 5 ",
-"JmsFmlyG 3615.887N 08649.846W 0000000m James Family Grocery by White ",
-"seekngrf 3629.262N 08742.333W 0000000m seekeing refuge by raf of the ",
-"SecrtFll 3614.927N 08534.180W 0000000m Secret Falls ",
-"ApstlcTh 3613.870N 08645.108W 0000000m Apostolic Thistle Walk by Jame",
-"WllIllBD 3609.258N 08637.268W 0000000m Well....I'll Be \"Dammed\" byi",
-"BettysBt 3608.857N 08550.564W 0000000m Betty's Booty by White Dog Pac",
-"SmthngSm 3439.748N 08643.522W 0000000m Something Smells Fishy by Zayb",
-"RckyRd(C 3605.315N 08549.326W 0000000m Rocky Road (Center Hill Lake) ",
-"Brdwtchr 3436.605N 08651.243W 0000000m Birdwatcher's Dream by Zaybex ",
-"JcksnsHl 3605.185N 08619.439W 0000000m Jackson's Halls by White Dog P",
-"FrgttnP2 3509.599N 08633.282W 0000000m Forgotten Park 2 ",
-"SOLDIERS 3640.691N 08726.660W 0000000m SOLDIERS TRIBUTE by Feros Fami",
-"EndofRop 3433.820N 08650.460W 0000000m End of Rope by Big Rock ",
-"VwthPst1 3659.263N 08627.114W 0000000m View the Past #1 ",
-"VwthPst2 3700.706N 08627.588W 0000000m View the Past #2 ",
-"Trash#8 3603.102N 08655.144W 0000000m Cache In Trash Out # 8 ",
-"SlwwwwCc 3602.543N 08535.953W 0000000m Sloowwww Cache by Tntcacher ",
-"Leavttbv 3602.514N 08638.686W 0000000m Leave it to beaver by A182pilo",
-"WhrrthHr 3436.594N 08654.759W 0000000m Where are the Horses? by Zaybe",
-"ButtonCc 3433.401N 08645.294W 0000000m Button Cache by Zaybex ",
-"MrcsLbrr 3436.842N 08655.972W 0000000m Marco's Library by Marco ",
-"Octopus 3526.743N 08534.757W 0000000m Octopus by White Dog Pack ",
-"WtrFllsV 3544.140N 08527.861W 0000000m Water Falls Valley by Cave Rat",
-"DeddrpPn 3448.126N 08719.696W 0000000m Dead-drop Pink by Marco ",
-"JWhlrRvr 3448.157N 08719.914W 0000000m Joe Wheeler River Walk by Marc",
-"CvSprngs 3432.797N 08651.084W 0000000m Cave Springs Cache by Marco.. ",
-"CnyFrkOv 3550.876N 08518.446W 0000000m Fork Overlook ",
-"SheepsCa 3550.527N 08519.480W 0000000m Sheep's Cave ",
-"VrgnFlls 3550.308N 08519.904W 0000000m Virgin Falls Cache ",
-"ShrtctVr 3550.170N 08519.590W 0000000m Shortcut Virtual ",
-"KlylFlls 3549.105N 08539.814W 0000000m Klaylee Falls Cache by pattytr",
-"FshngfrB 3548.923N 08538.558W 0000000m BADGER by M&Mk ",
-"TpfthHll 3548.808N 08601.722W 0000000m Top of the Hill Pet Cache by M",
-"TwnFllsC 3548.560N 08537.996W 0000000m Twin Falls Cache by SLCREW a",
-"WtchsCst 3548.197N 08537.673W 0000000m Witch's Castle Keys by SLCREW ",
-"ThatCave 3544.901N 08522.854W 0000000m That Cave by JaDan150 and AprJ",
-"BssltwnW 3541.174N 08801.489W 0000000m Busseltown Wildlife Refuge by ",
-"Riverfrn 3540.968N 08546.995W 0000000m Riverfront by SLCREW and M&M",
-"Basement 3540.086N 08521.304W 0000000m The Basement ",
-"EfflTwrC 3617.132N 08818.371W 0000000m Eiffel Tower Cache by Dick Wan",
-"KeyholeC 3544.562N 08524.098W 0000000m Keyhole Cave by Cave Rat ",
-"(MC^2)Mn 3444.990N 08630.218W 0000000m (MC^2) Monte Sano Cuts Cache b",
-"WildctCc 3636.823N 08808.087W 0000000m Wildcat Cache by The Storm ",
-"NAlbm/Tn 3444.365N 08632.688W 0000000m N. Alabama / Tennessee Valley ",
-"CalebsCa 3444.215N 08633.103W 0000000m Caleb's Cave by Papaw and Cale",
-"MntSnPrs 3444.201N 08632.591W 0000000m Monte Sano Preserve by Evan & ",
-"FltRckFl 3444.475N 08629.958W 0000000m Flat Rock Falls Cache by Jason",
-"PanormCc 3443.961N 08631.638W 0000000m The Panorama Cache by IHTFP an",
-"TnnssScv 3602.861N 08652.751W 0000000m Tennessee Scavenger Hunt Cache",
-"Geocache 3435.209N 08655.968W 0000000m Geocache by Papaw & Caleb ",
-"Skellig 3444.100N 08656.566W 0000000m Skellig by Zaybex ",
-"Deceptio 3433.450N 08655.711W 0000000m Deception by Papaw and Caleb ",
-"AwlknthD 3433.310N 08655.635W 0000000m A walk in the Desert by Papa",
-"MiniMsQs 3558.934N 08650.674W 0000000m Mini Me's Quest by CrotalusRex",
-"BakrsBlf 3541.891N 08717.300W 0000000m Bakers Bluff by Flower Child &",
-"GoFlyAKi 3435.664N 08659.267W 0000000m Go Fly A Kite by Marco.. ",
-"FlntCrkA 3432.028N 08656.806W 0000000m Flint Creek Adventure by Marco",
-"HonordMn 3534.680N 08612.557W 0000000m Honored Mount by Southpaw ",
-"SafariZo 3440.697N 08700.774W 0000000m Safari Zone by Zaybex ",
-"JckDnlsC 3517.077N 08622.260W 0000000m Jack Daniels Cache by Rmearse ",
-"FrgttnPr 3509.599N 08633.282W 0000000m Forgotten Park ",
-"DntOvrlk 3513.326N 08616.031W 0000000m Dont Overlook Me Cache ",
-"ArYStmpd 3513.039N 08615.110W 0000000m Are You Stumped Yet? cache ",
-"CchtthBn 3512.532N 08614.691W 0000000m Cache at the Bend ",
-"Thtsnkng 3609.009N 08530.314W 0000000m That sinking feeling by Tntcac",
-"GamersCc 3449.136N 08635.836W 0000000m mer's Cache by avoral ",
-"CchMIfYC 3452.455N 08620.648W 0000000m Cache Me If You Can! by Glen H",
-"SavageVs 3526.915N 08535.136W 0000000m Savage Vista by White Dog Pack",
-"PrtrnG15 3555.479N 08653.274W 0000000m Praetorian Guards Hail Caesar #15!",
-"WtrlnAmp 3443.722N 08632.535W 0000000m Waterline Amphitheater by Fath",
-"BysLttlC 3447.569N 08638.448W 0000000m Boys' Little Cache by Zaybex ",
-"DrgnsBrt 3443.779N 08635.188W 0000000m Dragon's Breath by Zaybex ",
-"CryBbyHl 3430.733N 08657.362W 0000000m Cry Baby Hollow Cache by La Pa",
-"Parmer 3606.218N 08651.590W 0000000m Parmer by A182pilot & Family ",
-"JnnfrndJ 3438.141N 08632.991W 0000000m Jennifer and Jonathans Cliff C",
-"ALDRIDGE 3435.305N 08632.868W 0000000m ALDRIDGE CREEK LOTTA LOOT!! by",
-"RcktCtyS 3440.032N 08631.352W 0000000m Rocket City Stash by David Upt",
-"TrgcAccd 3608.561N 08648.381W 0000000m Tragic Accident by Campaholics",
-"FALLENTR 3439.210N 08631.104W 0000000m FALLEN TREE 4 MILE POST by zac",
-"TrshOt15 3558.964N 08646.064W 0000000m Cache In Trash Out # 15 ",
-"TrshOt13 3602.214N 08650.428W 0000000m Cache In Trash Out #13 ",
-"PrcysDrp 3604.312N 08653.465W 0000000m Percys Dripping Springs by KLi",
-"TrshOt14 3605.292N 08648.560W 0000000m Cache In Trash Out # 14 ",
-"PrtrnGr5 3557.621N 08640.278W 0000000m Praetorian Guards Hail Caesar #5!",
-"PrtrnGr4 3557.370N 08640.201W 0000000m Praetorian Guards Hail Caesar #4!",
-"PrtrnGr3 3557.250N 08640.047W 0000000m Praetorian Guards Hail Caesar #3!",
-"GrnMntnC 3439.120N 08631.100W 0000000m Green Mountain Cache by Steve ",
-"TrshOt12 3605.330N 08635.817W 0000000m Cache In Trash Out #12 ",
-"BlncngAc 3608.579N 08648.120W 0000000m Balancing Act by Campaholics ",
-"DittoCac 3434.652N 08633.310W 0000000m Ditto Cache by mookey ",
-"EraserCc 3431.888N 08633.024W 0000000m Eraser Cache by Zaybex ",
-"FrMlPstE 3439.440N 08630.180W 0000000m Four Mile Post Extension Cache",
-"MllrdFxC 3439.578N 08706.552W 0000000m Mallard-Fox Creek Cache by bam",
-"FireCach 3443.908N 08630.318W 0000000m he by Glen Pam Chase M ",
-"FlntRvrC 3443.170N 08625.990W 0000000m Flint River Canoe Cache by Ran",
-"ArabinCc 3419.104N 08628.765W 0000000m The Arabian Cache by WesNSpace",
-"CvrdBrdg 3412.406N 08659.392W 0000000m Covered Bridge Cache by pmarkh",
-"MilesTCc 3424.470N 08611.720W 0000000m Miles Too Cache by Rmearse ",
-"MbryOvrl 3423.803N 08611.922W 0000000m Mabrey Overlook Me by DDVaughn",
-"LwEnfrcm 3423.218N 08612.258W 0000000m Law Enforcement Cache by DDVau",
-"GrndDddy 3423.128N 08612.025W 0000000m Grand Daddys Home by Rmearse ",
-"BamaCach 3421.459N 08611.686W 0000000m The Bama Cache by DDVaughn & T",
-"Canyons 3440.085N 08600.910W 0000000m The Canyons by Aubrey and Josh",
-"ADamGodV 3511.677N 08616.587W 0000000m A Dam Good View by mdawg & muf",
-"UNDERTHE 3446.918N 08739.790W 0000000m UNDER THE ROCK by RUNNINGWILD ",
-"SQUIRREL 3448.712N 08741.681W 0000000m SQUIRREL'S NEST by RUNNINGWILD",
-"WlknthPr 3448.273N 08741.844W 0000000m Walk in the Park by Runningwil",
-"NetsClue 3448.494N 08741.977W 0000000m Net's Clues by Runningwild Adv",
-"NatrlBrd 3405.583N 08736.909W 0000000m Natural Bridge by Southeast Xt",
-"TrnglPrk 3341.448N 08640.980W 0000000m Triangle Park Cache by Charles",
-"LttlRvrI 3421.855N 08539.597W 0000000m Little River Initiative by spa",
-"GimmShlt 3430.087N 08536.834W 0000000m Gimme Shelter by Big Rock & Po",
-"GnomeTrs 3433.081N 08535.849W 0000000m Gnome Treasure by Big Rock ",
-"FlyingTr 3608.594N 08648.179W 0000000m Flying Torso by Campaholics ",
-"CultivtC 3608.582N 08648.064W 0000000m Cultivate a Cure by Campahol"
+char* foo[] = {
+ "VwthPst# 3700.706N 08627.588W 0000000m View the Past #2 ",
+ "PilotRoc 3655.270N 08717.173W 0000000m Pilot Rock ",
+ "MrCycsNg 3652.407N 08728.890W 0000000m Mr. Cayces Neighborhood ",
+ "SOLDIER 3640.691N 08726.660W 0000000m SOLDIER’S TRIBUTE ",
+ "ZOOMZOOM 3636.659N 08721.793W 0000000m ZOOM ZOOM ZOOM by Feros Family",
+ "SOCLOSEB 3636.494N 08722.086W 0000000m SO CLOSE BUT YET by Kyle of Fe",
+ "InSrchfS 3636.363N 08636.363W 0000000m In Search of Steam by BigHank ",
+ "RdBlngSp 3632.119N 08550.956W 0000000m Red Boiling Springs by Firedog",
+ "HelngWtr 3631.729N 08550.481W 0000000m Healing Waters by FiredogPotte",
+ "AHHtheVi 3629.020N 08533.891W 0000000m ogPotter ",
+ "LstCrkCc 3628.167N 08801.656W 0000000m Lost Creek Cache by Paul Kathy",
+ "DlvrncTr 3626.412N 08729.249W 0000000m Deliverance Train by Team Skay",
+ "FrQrtrRn 3438.502N 08646.926W 0000000m Four Quarter Rendezvous by Zay",
+ "Jstlttlc 3620.647N 08814.298W 0000000m Just a little cache by Paul Ka",
+ "BrryPtch 3618.786N 08616.344W 0000000m Berry Patch Cache by White Dog",
+ "AStrllDw 3342.752N 08630.829W 0000000m A Stroll Down Memory Lane by t",
+ "QunfTnns 3606.413N 08651.962W 0000000m Queen of Tennessee by A182pilo",
+ "GoneFish 3618.199N 08655.171W 0000000m Gone Fishin' by White Dog Pack",
+ "GrnwysFn 3610.942N 08642.061W 0000000m Greenways Fence by Ukulele And",
+ "AStnsThr 3611.240N 08638.324W 0000000m A Stone's Throw by Murrcat & S",
+ "Nashvlls 3617.112N 08642.359W 0000000m Nashville's Zoo by White Dog P",
+ "BltzMcr4 3517.127N 08622.211W 0000000m Blitz Micro Number 4 ",
+ "NkdnthWn 3437.145N 08651.693W 0000000m Naked in the Wind by Zaybex ",
+ "ANcPlctR 3603.389N 08654.418W 0000000m A Nice Place to Rest by JoGPS ",
+ "welcomtT 3638.155N 08720.130W 0000000m welcome to TN by Raf of the se",
+ "welcomtK 3638.956N 08721.011W 0000000m welcome to KY by raf of the se",
+ "BltzMcr5 3506.191N 08634.277W 0000000m Blitz Micro Number 5 ",
+ "JmsFmlyG 3615.887N 08649.846W 0000000m James Family Grocery by White ",
+ "seekngrf 3629.262N 08742.333W 0000000m seekeing refuge by raf of the ",
+ "SecrtFll 3614.927N 08534.180W 0000000m Secret Falls ",
+ "ApstlcTh 3613.870N 08645.108W 0000000m Apostolic Thistle Walk by Jame",
+ "WllIllBD 3609.258N 08637.268W 0000000m Well....I'll Be \"Dammed\" byi",
+ "BettysBt 3608.857N 08550.564W 0000000m Betty's Booty by White Dog Pac",
+ "SmthngSm 3439.748N 08643.522W 0000000m Something Smells Fishy by Zayb",
+ "RckyRd(C 3605.315N 08549.326W 0000000m Rocky Road (Center Hill Lake) ",
+ "Brdwtchr 3436.605N 08651.243W 0000000m Birdwatcher's Dream by Zaybex ",
+ "JcksnsHl 3605.185N 08619.439W 0000000m Jackson's Halls by White Dog P",
+ "FrgttnP2 3509.599N 08633.282W 0000000m Forgotten Park 2 ",
+ "SOLDIERS 3640.691N 08726.660W 0000000m SOLDIERS TRIBUTE by Feros Fami",
+ "EndofRop 3433.820N 08650.460W 0000000m End of Rope by Big Rock ",
+ "VwthPst1 3659.263N 08627.114W 0000000m View the Past #1 ",
+ "VwthPst2 3700.706N 08627.588W 0000000m View the Past #2 ",
+ "Trash#8 3603.102N 08655.144W 0000000m Cache In Trash Out # 8 ",
+ "SlwwwwCc 3602.543N 08535.953W 0000000m Sloowwww Cache by Tntcacher ",
+ "Leavttbv 3602.514N 08638.686W 0000000m Leave it to beaver by A182pilo",
+ "WhrrthHr 3436.594N 08654.759W 0000000m Where are the Horses? by Zaybe",
+ "ButtonCc 3433.401N 08645.294W 0000000m Button Cache by Zaybex ",
+ "MrcsLbrr 3436.842N 08655.972W 0000000m Marco's Library by Marco ",
+ "Octopus 3526.743N 08534.757W 0000000m Octopus by White Dog Pack ",
+ "WtrFllsV 3544.140N 08527.861W 0000000m Water Falls Valley by Cave Rat",
+ "DeddrpPn 3448.126N 08719.696W 0000000m Dead-drop Pink by Marco ",
+ "JWhlrRvr 3448.157N 08719.914W 0000000m Joe Wheeler River Walk by Marc",
+ "CvSprngs 3432.797N 08651.084W 0000000m Cave Springs Cache by Marco.. ",
+ "CnyFrkOv 3550.876N 08518.446W 0000000m Fork Overlook ",
+ "SheepsCa 3550.527N 08519.480W 0000000m Sheep's Cave ",
+ "VrgnFlls 3550.308N 08519.904W 0000000m Virgin Falls Cache ",
+ "ShrtctVr 3550.170N 08519.590W 0000000m Shortcut Virtual ",
+ "KlylFlls 3549.105N 08539.814W 0000000m Klaylee Falls Cache by pattytr",
+ "FshngfrB 3548.923N 08538.558W 0000000m BADGER by M&Mk ",
+ "TpfthHll 3548.808N 08601.722W 0000000m Top of the Hill Pet Cache by M",
+ "TwnFllsC 3548.560N 08537.996W 0000000m Twin Falls Cache by SLCREW a",
+ "WtchsCst 3548.197N 08537.673W 0000000m Witch's Castle Keys by SLCREW ",
+ "ThatCave 3544.901N 08522.854W 0000000m That Cave by JaDan150 and AprJ",
+ "BssltwnW 3541.174N 08801.489W 0000000m Busseltown Wildlife Refuge by ",
+ "Riverfrn 3540.968N 08546.995W 0000000m Riverfront by SLCREW and M&M",
+ "Basement 3540.086N 08521.304W 0000000m The Basement ",
+ "EfflTwrC 3617.132N 08818.371W 0000000m Eiffel Tower Cache by Dick Wan",
+ "KeyholeC 3544.562N 08524.098W 0000000m Keyhole Cave by Cave Rat ",
+ "(MC^2)Mn 3444.990N 08630.218W 0000000m (MC^2) Monte Sano Cuts Cache b",
+ "WildctCc 3636.823N 08808.087W 0000000m Wildcat Cache by The Storm ",
+ "NAlbm/Tn 3444.365N 08632.688W 0000000m N. Alabama / Tennessee Valley ",
+ "CalebsCa 3444.215N 08633.103W 0000000m Caleb's Cave by Papaw and Cale",
+ "MntSnPrs 3444.201N 08632.591W 0000000m Monte Sano Preserve by Evan & ",
+ "FltRckFl 3444.475N 08629.958W 0000000m Flat Rock Falls Cache by Jason",
+ "PanormCc 3443.961N 08631.638W 0000000m The Panorama Cache by IHTFP an",
+ "TnnssScv 3602.861N 08652.751W 0000000m Tennessee Scavenger Hunt Cache",
+ "Geocache 3435.209N 08655.968W 0000000m Geocache by Papaw & Caleb ",
+ "Skellig 3444.100N 08656.566W 0000000m Skellig by Zaybex ",
+ "Deceptio 3433.450N 08655.711W 0000000m Deception by Papaw and Caleb ",
+ "AwlknthD 3433.310N 08655.635W 0000000m A walk in the Desert by Papa",
+ "MiniMsQs 3558.934N 08650.674W 0000000m Mini Me's Quest by CrotalusRex",
+ "BakrsBlf 3541.891N 08717.300W 0000000m Bakers Bluff by Flower Child &",
+ "GoFlyAKi 3435.664N 08659.267W 0000000m Go Fly A Kite by Marco.. ",
+ "FlntCrkA 3432.028N 08656.806W 0000000m Flint Creek Adventure by Marco",
+ "HonordMn 3534.680N 08612.557W 0000000m Honored Mount by Southpaw ",
+ "SafariZo 3440.697N 08700.774W 0000000m Safari Zone by Zaybex ",
+ "JckDnlsC 3517.077N 08622.260W 0000000m Jack Daniels Cache by Rmearse ",
+ "FrgttnPr 3509.599N 08633.282W 0000000m Forgotten Park ",
+ "DntOvrlk 3513.326N 08616.031W 0000000m Dont Overlook Me Cache ",
+ "ArYStmpd 3513.039N 08615.110W 0000000m Are You Stumped Yet? cache ",
+ "CchtthBn 3512.532N 08614.691W 0000000m Cache at the Bend ",
+ "Thtsnkng 3609.009N 08530.314W 0000000m That sinking feeling by Tntcac",
+ "GamersCc 3449.136N 08635.836W 0000000m mer's Cache by avoral ",
+ "CchMIfYC 3452.455N 08620.648W 0000000m Cache Me If You Can! by Glen H",
+ "SavageVs 3526.915N 08535.136W 0000000m Savage Vista by White Dog Pack",
+ "PrtrnG15 3555.479N 08653.274W 0000000m Praetorian Guards Hail Caesar #15!",
+ "WtrlnAmp 3443.722N 08632.535W 0000000m Waterline Amphitheater by Fath",
+ "BysLttlC 3447.569N 08638.448W 0000000m Boys' Little Cache by Zaybex ",
+ "DrgnsBrt 3443.779N 08635.188W 0000000m Dragon's Breath by Zaybex ",
+ "CryBbyHl 3430.733N 08657.362W 0000000m Cry Baby Hollow Cache by La Pa",
+ "Parmer 3606.218N 08651.590W 0000000m Parmer by A182pilot & Family ",
+ "JnnfrndJ 3438.141N 08632.991W 0000000m Jennifer and Jonathans Cliff C",
+ "ALDRIDGE 3435.305N 08632.868W 0000000m ALDRIDGE CREEK LOTTA LOOT!! by",
+ "RcktCtyS 3440.032N 08631.352W 0000000m Rocket City Stash by David Upt",
+ "TrgcAccd 3608.561N 08648.381W 0000000m Tragic Accident by Campaholics",
+ "FALLENTR 3439.210N 08631.104W 0000000m FALLEN TREE 4 MILE POST by zac",
+ "TrshOt15 3558.964N 08646.064W 0000000m Cache In Trash Out # 15 ",
+ "TrshOt13 3602.214N 08650.428W 0000000m Cache In Trash Out #13 ",
+ "PrcysDrp 3604.312N 08653.465W 0000000m Percys Dripping Springs by KLi",
+ "TrshOt14 3605.292N 08648.560W 0000000m Cache In Trash Out # 14 ",
+ "PrtrnGr5 3557.621N 08640.278W 0000000m Praetorian Guards Hail Caesar #5!",
+ "PrtrnGr4 3557.370N 08640.201W 0000000m Praetorian Guards Hail Caesar #4!",
+ "PrtrnGr3 3557.250N 08640.047W 0000000m Praetorian Guards Hail Caesar #3!",
+ "GrnMntnC 3439.120N 08631.100W 0000000m Green Mountain Cache by Steve ",
+ "TrshOt12 3605.330N 08635.817W 0000000m Cache In Trash Out #12 ",
+ "BlncngAc 3608.579N 08648.120W 0000000m Balancing Act by Campaholics ",
+ "DittoCac 3434.652N 08633.310W 0000000m Ditto Cache by mookey ",
+ "EraserCc 3431.888N 08633.024W 0000000m Eraser Cache by Zaybex ",
+ "FrMlPstE 3439.440N 08630.180W 0000000m Four Mile Post Extension Cache",
+ "MllrdFxC 3439.578N 08706.552W 0000000m Mallard-Fox Creek Cache by bam",
+ "FireCach 3443.908N 08630.318W 0000000m he by Glen Pam Chase M ",
+ "FlntRvrC 3443.170N 08625.990W 0000000m Flint River Canoe Cache by Ran",
+ "ArabinCc 3419.104N 08628.765W 0000000m The Arabian Cache by WesNSpace",
+ "CvrdBrdg 3412.406N 08659.392W 0000000m Covered Bridge Cache by pmarkh",
+ "MilesTCc 3424.470N 08611.720W 0000000m Miles Too Cache by Rmearse ",
+ "MbryOvrl 3423.803N 08611.922W 0000000m Mabrey Overlook Me by DDVaughn",
+ "LwEnfrcm 3423.218N 08612.258W 0000000m Law Enforcement Cache by DDVau",
+ "GrndDddy 3423.128N 08612.025W 0000000m Grand Daddys Home by Rmearse ",
+ "BamaCach 3421.459N 08611.686W 0000000m The Bama Cache by DDVaughn & T",
+ "Canyons 3440.085N 08600.910W 0000000m The Canyons by Aubrey and Josh",
+ "ADamGodV 3511.677N 08616.587W 0000000m A Dam Good View by mdawg & muf",
+ "UNDERTHE 3446.918N 08739.790W 0000000m UNDER THE ROCK by RUNNINGWILD ",
+ "SQUIRREL 3448.712N 08741.681W 0000000m SQUIRREL'S NEST by RUNNINGWILD",
+ "WlknthPr 3448.273N 08741.844W 0000000m Walk in the Park by Runningwil",
+ "NetsClue 3448.494N 08741.977W 0000000m Net's Clues by Runningwild Adv",
+ "NatrlBrd 3405.583N 08736.909W 0000000m Natural Bridge by Southeast Xt",
+ "TrnglPrk 3341.448N 08640.980W 0000000m Triangle Park Cache by Charles",
+ "LttlRvrI 3421.855N 08539.597W 0000000m Little River Initiative by spa",
+ "GimmShlt 3430.087N 08536.834W 0000000m Gimme Shelter by Big Rock & Po",
+ "GnomeTrs 3433.081N 08535.849W 0000000m Gnome Treasure by Big Rock ",
+ "FlyingTr 3608.594N 08648.179W 0000000m Flying Torso by Campaholics ",
+ "CultivtC 3608.582N 08648.064W 0000000m Cultivate a Cure by Campahol"
}
;
- extern "C" {
- struct short_handle *mkshort_new_handle(void);
- char * mkshort (struct short_handle *, char*);
- void setshort_whitespace_ok(struct short_handle *, int n);
- }
+extern "C" {
+ struct short_handle* mkshort_new_handle(void);
+ char* mkshort(struct short_handle*, char*);
+ void setshort_whitespace_ok(struct short_handle*, int n);
+}
main()
{
- char **foop = foo;
- bool r;
- Shortname sn;
+ char** foop = foo;
+ bool r;
+ Shortname sn;
// printf("%s\n", qPrintable(sn.Shorten("The Troll")));
#if 0
- printf("%s\n", mkshort("The Troll"));
- printf("%s\n", mkshort("EFI"));
- printf("%s\n", mkshort("the Troll"));
- printf("%s\n", mkshort("the Trolley"));
- printf("%s\n", mkshort("The Troll Lives Under The Bridge"));
- printf("%s\n", mkshort("The \"Troll\" Lives Under $$ The Bridge!"));
- printf("%s\n", mkshort("The Trolley Goes Round"));
- printf("%s\n", mkshort("Cache In / Trash Out #1"));
- printf("%s\n", mkshort("Cache In / Trash Out #2"));
- printf("%s\n", mkshort("Cache In / Trash Out #137"));
+ printf("%s\n", mkshort("The Troll"));
+ printf("%s\n", mkshort("EFI"));
+ printf("%s\n", mkshort("the Troll"));
+ printf("%s\n", mkshort("the Trolley"));
+ printf("%s\n", mkshort("The Troll Lives Under The Bridge"));
+ printf("%s\n", mkshort("The \"Troll\" Lives Under $$ The Bridge!"));
+ printf("%s\n", mkshort("The Trolley Goes Round"));
+ printf("%s\n", mkshort("Cache In / Trash Out #1"));
+ printf("%s\n", mkshort("Cache In / Trash Out #2"));
+ printf("%s\n", mkshort("Cache In / Trash Out #137"));
#endif
#if 1
- struct short_handle *mh = mkshort_new_handle();
- setshort_whitespace_ok(mh, 0);
+ struct short_handle* mh = mkshort_new_handle();
+ setshort_whitespace_ok(mh, 0);
- sn.target_length(8);
- sn.whitespace_ok(false);
+ sn.target_length(8);
+ sn.whitespace_ok(false);
- while (*foop) {
+ while (*foop) {
// printf("%s %s\n", mkshort(*foop+39), *foop+39);
- QString s = sn.Shorten(*foop + 39);
- QString r = (*foop);
- r.truncate(8);
+ QString s = sn.Shorten(*foop + 39);
+ QString r = (*foop);
+ r.truncate(8);
//fprintf(stderr, "zzz%s\n", *foop + 39);
- char *os = mkshort (mh, *foop + 39);
-if (s != os) {
- fprintf(stderr, "%s/%s\n", qPrintable(r), os);
-}
- // assert(r == s);
- foop++;
- }
+ char* os = mkshort(mh, *foop + 39);
+ if (s != os) {
+ fprintf(stderr, "%s/%s\n", qPrintable(r), os);
+ }
+ // assert(r == s);
+ foop++;
+ }
#endif
#define X(a,b) assert(a == sn.Shorten(b));
X("GC12345", "GC12345");
X("eat a pc", "eat a peach");
X("eat a or", "eat a orange");
- printf("%s\n", qPrintable(Shortname::DeleteLastVowel(5, "eat a peach", r)));
-printf("%s\n", qPrintable(Shortname::DeleteLastVowel(5, "eat a orange", r)));
+ printf("%s\n", qPrintable(Shortname::DeleteLastVowel(5, "eat a peach", r)));
+ printf("%s\n", qPrintable(Shortname::DeleteLastVowel(5, "eat a orange", r)));
-printf("%s\n", qPrintable(Shortname::DeleteLastVowel(0, "the quick brown foo", r)));
-printf("%s\n", qPrintable(Shortname::DeleteLastVowel(0, "the quick brown fox", r)));
-printf("%s\n", qPrintable(Shortname::DeleteLastVowel(0, "eat a peach", r)));
-printf("%s\n", qPrintable(Shortname::DeleteLastVowel(5, "eat a peach", r)));
-printf("%s\n", qPrintable(Shortname::DeleteLastVowel(5, "eat a orange", r)));
-printf("%s\n", qPrintable(Shortname::DeleteLastVowel(0, "xxx", r)));
-printf("%s\n", qPrintable(Shortname::DeleteLastVowel(0, "ixxx", r)));
-printf("%s\n", qPrintable(Shortname::DeleteLastVowel(0, "aexxx", r)));
+ printf("%s\n", qPrintable(Shortname::DeleteLastVowel(0, "the quick brown foo", r)));
+ printf("%s\n", qPrintable(Shortname::DeleteLastVowel(0, "the quick brown fox", r)));
+ printf("%s\n", qPrintable(Shortname::DeleteLastVowel(0, "eat a peach", r)));
+ printf("%s\n", qPrintable(Shortname::DeleteLastVowel(5, "eat a peach", r)));
+ printf("%s\n", qPrintable(Shortname::DeleteLastVowel(5, "eat a orange", r)));
+ printf("%s\n", qPrintable(Shortname::DeleteLastVowel(0, "xxx", r)));
+ printf("%s\n", qPrintable(Shortname::DeleteLastVowel(0, "ixxx", r)));
+ printf("%s\n", qPrintable(Shortname::DeleteLastVowel(0, "aexxx", r)));
}
#endif
ARG_TERMINATOR
};
-static gbfile *fin, *fout;
+static gbfile* fin, *fout;
static int rte_num, wpt_num;
static short_handle short_h;
-static const waypoint *prev_wpt;
+static const waypoint* prev_wpt;
-static waypoint *
-skyforce_parse_coords(const char *str)
+static waypoint*
+skyforce_parse_coords(const char* str)
{
- waypoint *wpt;
+ waypoint* wpt;
if (strlen(str) < 38) {
fatal(MYNAME ": Incomplete line!\n");
}
-static waypoint *
-skyforce_parse_wpt(const char *str, int *rte_num)
+static waypoint*
+skyforce_parse_wpt(const char* str, int* rte_num)
{
- waypoint *wpt;
+ waypoint* wpt;
wpt = skyforce_parse_coords(str);
if (wpt == NULL) {
}
-static waypoint *
-skyforce_parse_trk(const char *str)
+static waypoint*
+skyforce_parse_trk(const char* str)
{
- char *cx;
+ char* cx;
struct tm tm;
char buf[15];
int len;
- waypoint *wpt;
+ waypoint* wpt;
wpt = skyforce_parse_coords(str);
if (wpt == NULL) {
static void
-skyforce_head_disp_cb(const route_head *head)
+skyforce_head_disp_cb(const route_head* head)
{
prev_wpt = NULL;
if (head->rte_waypt_ct <= 0) {
static void
-skyforce_waypt_disp_cb(const waypoint *wpt)
+skyforce_waypt_disp_cb(const waypoint* wpt)
{
char buf[75]; /* long enough for all data types */
double lat, lon;
tm = *gmtime(&tt);
strftime(buf + 2, sizeof(buf) - 2, "%d%m%y %H%M%S ", &tm);
} else {
- char *name;
+ char* name;
if (rte_num > 999) {
return;
*******************************************************************************/
static void
-skyforce_rd_init(const char *fname)
+skyforce_rd_init(const char* fname)
{
fin = gbfopen(fname, "r", MYNAME);
}
static void
skyforce_read(void)
{
- char *str;
- route_head *rte, *trk;
+ char* str;
+ route_head* rte, *trk;
wpt_num = 0;
rte = trk = NULL;
while ((str = gbfgetstr(fin))) {
- waypoint *wpt;
+ waypoint* wpt;
int i;
str = lrtrim(str);
static void
-skyforce_wr_init(const char *fname)
+skyforce_wr_init(const char* fname)
{
fout = gbfopen(fname, "w", MYNAME);
#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
-static char *port; /* port name */
-static void *serial_handle = 0; /* IO file descriptor */
+static char* port; /* port name */
+static void* serial_handle = 0; /* IO file descriptor */
static int skytraq_baud = 0; /* detected baud rate */
-static gbfile *file_handle = 0; /* file descriptor (used by skytraq-bin format) */
-
-static char *opt_erase = 0; /* erase after read? (0/1) */
-static char *opt_initbaud = 0; /* baud rate used to init device */
-static char *opt_dlbaud = 0; /* baud rate used for downloading tracks */
-static char *opt_read_at_once = 0; /* number of sectors to read at once (Venus6 only) */
-static char *opt_first_sector = 0; /* first sector to be read from the device (default: 0) */
-static char *opt_last_sector = 0; /* last sector to be read from the device (default: smart read everything) */
-static char *opt_dump_file = 0; /* dump raw data to this file (optional) */
-static char *opt_no_output = 0; /* disable output? (0/1) */
-static char *opt_set_location = 0; /* set if the "targetlocation" options was used */
-static char *opt_configure_logging = 0;
+static gbfile* file_handle = 0; /* file descriptor (used by skytraq-bin format) */
+
+static char* opt_erase = 0; /* erase after read? (0/1) */
+static char* opt_initbaud = 0; /* baud rate used to init device */
+static char* opt_dlbaud = 0; /* baud rate used for downloading tracks */
+static char* opt_read_at_once = 0; /* number of sectors to read at once (Venus6 only) */
+static char* opt_first_sector = 0; /* first sector to be read from the device (default: 0) */
+static char* opt_last_sector = 0; /* last sector to be read from the device (default: smart read everything) */
+static char* opt_dump_file = 0; /* dump raw data to this file (optional) */
+static char* opt_no_output = 0; /* disable output? (0/1) */
+static char* opt_set_location = 0; /* set if the "targetlocation" options was used */
+static char* opt_configure_logging = 0;
static
arglist_t skytraq_args[] = {
};
static void
-db(int l, const char *msg, ...)
+db(int l, const char* msg, ...)
{
va_list ap;
va_start(ap, msg);
}
static int
-rd_char(int *errors)
+rd_char(int* errors)
{
int c;
while (*errors > 0) {
}
static int
-rd_buf(const uint8_t *buf, int len)
+rd_buf(const uint8_t* buf, int len)
{
int rc, timeout, i;
char dump[16*3+16+2];
}
static void
-wr_buf(const unsigned char *str, int len)
+wr_buf(const unsigned char* str, int len)
{
int i;
for (i = 0; i < len; i++) {
uint8_t SECTOR_READ_END[13] = { 'E','N','D', 0, 'C','H','E','C','K','S','U','M','=' };
static int
-skytraq_calc_checksum(const unsigned char *buf, int len)
+skytraq_calc_checksum(const unsigned char* buf, int len)
{
int i, cs = 0;
for (i = 0; i < len; i++) {
}
static int
-skytraq_rd_msg(const void *payload, unsigned int len)
+skytraq_rd_msg(const void* payload, unsigned int len)
{
int errors = 5; /* allow this many errors */
unsigned int c, i, state;
}
static void
-skytraq_wr_msg(const uint8_t *payload, int len)
+skytraq_wr_msg(const uint8_t* payload, int len)
{
int cs;
}
static int
-skytraq_expect_msg(uint8_t id, const uint8_t *payload, int len)
+skytraq_expect_msg(uint8_t id, const uint8_t* payload, int len)
{
int i, rc;
}
static int
-skytraq_wr_msg_verify(const uint8_t *payload, int len)
+skytraq_wr_msg_verify(const uint8_t* payload, int len)
{
int i, rc;
static int
skytraq_configure_logging(void)
{
- // an0008-1.4.14: logs if
- // (dt > tmin & dd >= dmin & v >= vmin) | dt > tmax | dd > dmax | v > vmax
- unsigned int tmin=6, tmax=3600, dmin=0, dmax=10000, nn=0;
- uint8_t MSG_LOG_CONFIGURE_CONTROL[] = {
- 0x18, // message_id
- 0x00, 0x00, 0x0e, 0x10, // max_time: was 0x0000ffff (big endian!)
- 0x00, 0x00, 0x00, 0x06, // min_time: was 0x00000005
- 0x00, 0x00, 0x27, 0x10, // max_distance: was 0x0000ffff
- 0x00, 0x00, 0x00, 0x00, // min_distance
- 0x00, 0x00, 0xff, 0xff, // max_speed
- 0x00, 0x00, 0x00, 0x00, // min_speed
- 0x01, // datalog_enable: NOTE: always ON
- 0x00 // reserved
- };
-
- if(opt_configure_logging) {
- if(*opt_configure_logging) {
- nn = sscanf(opt_configure_logging, "%u:%u:%u:%u", &tmin, &tmax, &dmin, &dmax);
- if(nn>3) {
- db(0, "Reconfiguring logging to: tmin=%u, tmax=%u, dmin=%u, dmax=%u\n", tmin, tmax, dmin, dmax );
- be_write32(MSG_LOG_CONFIGURE_CONTROL+5, tmin);
- be_write32(MSG_LOG_CONFIGURE_CONTROL+1, tmax);
- be_write32(MSG_LOG_CONFIGURE_CONTROL+13, dmin);
- be_write32(MSG_LOG_CONFIGURE_CONTROL+9, dmax);
- } else {
- db(1, MYNAME "Option usage: configlog=tmin:tmax:dmin:dmax");
- return -1;
- }
+ // an0008-1.4.14: logs if
+ // (dt > tmin & dd >= dmin & v >= vmin) | dt > tmax | dd > dmax | v > vmax
+ unsigned int tmin=6, tmax=3600, dmin=0, dmax=10000, nn=0;
+ uint8_t MSG_LOG_CONFIGURE_CONTROL[] = {
+ 0x18, // message_id
+ 0x00, 0x00, 0x0e, 0x10, // max_time: was 0x0000ffff (big endian!)
+ 0x00, 0x00, 0x00, 0x06, // min_time: was 0x00000005
+ 0x00, 0x00, 0x27, 0x10, // max_distance: was 0x0000ffff
+ 0x00, 0x00, 0x00, 0x00, // min_distance
+ 0x00, 0x00, 0xff, 0xff, // max_speed
+ 0x00, 0x00, 0x00, 0x00, // min_speed
+ 0x01, // datalog_enable: NOTE: always ON
+ 0x00 // reserved
+ };
+
+ if (opt_configure_logging) {
+ if (*opt_configure_logging) {
+ nn = sscanf(opt_configure_logging, "%u:%u:%u:%u", &tmin, &tmax, &dmin, &dmax);
+ if (nn>3) {
+ db(0, "Reconfiguring logging to: tmin=%u, tmax=%u, dmin=%u, dmax=%u\n", tmin, tmax, dmin, dmax);
+ be_write32(MSG_LOG_CONFIGURE_CONTROL+5, tmin);
+ be_write32(MSG_LOG_CONFIGURE_CONTROL+1, tmax);
+ be_write32(MSG_LOG_CONFIGURE_CONTROL+13, dmin);
+ be_write32(MSG_LOG_CONFIGURE_CONTROL+9, dmax);
+ } else {
+ db(1, MYNAME "Option usage: configlog=tmin:tmax:dmin:dmax");
+ return -1;
}
- }
+ }
+ }
- return skytraq_wr_msg_verify(MSG_LOG_CONFIGURE_CONTROL, sizeof(MSG_LOG_CONFIGURE_CONTROL));
+ return skytraq_wr_msg_verify(MSG_LOG_CONFIGURE_CONTROL, sizeof(MSG_LOG_CONFIGURE_CONTROL));
}
static int
-skytraq_get_log_buffer_status(uint32_t *log_wr_ptr, uint16_t *sectors_free, uint16_t *sectors_total)
+skytraq_get_log_buffer_status(uint32_t* log_wr_ptr, uint16_t* sectors_free, uint16_t* sectors_total)
{
uint8_t MSG_LOG_STATUS_CONTROL = 0x17;
struct {
}
/* reads 32-bit "middle-endian" fields */
-static unsigned int me_read32(const unsigned char *p)
+static unsigned int me_read32(const unsigned char* p)
{
return ((unsigned)be_read16(p+2) << 16) | ((unsigned)be_read16(p));
}
/* leap second compensation: */
gps_timet -= 13; /* diff GPS-UTC=13s (valid from Jan 01 1999 on) */
- if (gps_timet >= 1136073600) /* Jan 01 2006 0:00 UTC */
- gps_timet--; /* GPS-UTC = 14s */
- if (gps_timet >= 1230768000) /* Jan 01 2009 0:00 UTC */
- gps_timet--; /* GPS-UTC = 15s */
- if (gps_timet >= 1341100800) /* Jul 01 2012 0:00 UTC */
- gps_timet--; /* GPS-UTC = 16s */
+ if (gps_timet >= 1136073600) { /* Jan 01 2006 0:00 UTC */
+ gps_timet--; /* GPS-UTC = 14s */
+ }
+ if (gps_timet >= 1230768000) { /* Jan 01 2009 0:00 UTC */
+ gps_timet--; /* GPS-UTC = 15s */
+ }
+ if (gps_timet >= 1341100800) { /* Jul 01 2012 0:00 UTC */
+ gps_timet--; /* GPS-UTC = 16s */
+ }
return gps_timet; /* returns UTC time */
}
static void
-ECEF_to_LLA(double x, double y, long z, double *lat, double *lon, double *alt)
+ECEF_to_LLA(double x, double y, long z, double* lat, double* lon, double* alt)
{
/* constants: */
const double CA = 6378137.0;
}
struct read_state {
- route_head *route_head_;
+ route_head* route_head_;
unsigned wpn, tpn;
unsigned gps_week;
};
static void
-state_init(struct read_state *pst)
+state_init(struct read_state* pst)
{
- route_head *track;
+ route_head* track;
track = route_head_alloc();
track->rte_name = xstrdup("SkyTraq tracklog");
pst->z = 0;
}
-static waypoint *
-make_trackpoint(struct read_state *st, double lat, double lon, double alt)
+static waypoint*
+make_trackpoint(struct read_state* st, double lat, double lon, double alt)
{
- waypoint *wpt = waypt_new();
+ waypoint* wpt = waypt_new();
xasprintf(&wpt->shortname, "TP%04d", ++st->tpn);
#define ITEM_SPEED(item) (item->type_and_speed[1] | ((item->type_and_speed[0] & 0x0F) << 8))
static int
-process_data_item(struct read_state *pst, const item_frame *pitem, int len)
+process_data_item(struct read_state* pst, const item_frame* pitem, int len)
{
int res = 0;
double lat, lon, alt;
int poi = 0;
full_item f;
compact_item c;
- waypoint *tpt = NULL;
+ waypoint* tpt = NULL;
switch (ITEM_TYPE(pitem)) {
case 0x6: /* POI item (same structure as full) */
}
static int /* returns number of bytes processed (terminates on 0xFF i.e. empty or padding bytes) */
-process_data_sector(struct read_state *pst, const uint8_t *buf, int len)
+process_data_sector(struct read_state* pst, const uint8_t* buf, int len)
{
int plen, ilen;
/* Note: the buffer is being padded with 0xFFs if necessary so there are always SECTOR_SIZE valid bytes */
static int
-skytraq_read_single_sector(unsigned int sector, uint8_t *buf)
+skytraq_read_single_sector(unsigned int sector, uint8_t* buf)
{
uint8_t MSG_LOG_SECTOR_READ_CONTROL[2] = { 0x1B, (uint8_t)(sector) };
int errors = 5; /* allow this many errors */
}
static int
-skytraq_read_multiple_sectors(int first_sector, unsigned int sector_count, uint8_t *buf)
+skytraq_read_multiple_sectors(int first_sector, unsigned int sector_count, uint8_t* buf)
{
uint8_t MSG_LOG_READ_MULTI_SECTORS[5] = { 0x1D };
- uint8_t *buf_end_tag;
+ uint8_t* buf_end_tag;
unsigned int cs, i, read_result;
if (first_sector < 0 || first_sector > 0xFFFF) {
int opt_first_sector_val = atoi(opt_first_sector);
int opt_last_sector_val = atoi(opt_last_sector);
int multi_read_supported = 1;
- uint8_t *buffer = NULL;
- gbfile *dumpfile = NULL;
+ uint8_t* buffer = NULL;
+ gbfile* dumpfile = NULL;
state_init(&st);
*******************************************************************************/
static void
-skytraq_rd_init(const char *fname)
+skytraq_rd_init(const char* fname)
{
port = xstrdup(fname);
if ((serial_handle = gbser_init(fname)) == NULL) {
return;
}
- if(*opt_configure_logging) {
- skytraq_configure_logging();
- return;
+ if (*opt_configure_logging) {
+ skytraq_configure_logging();
+ return;
}
dlbaud = atoi(opt_dlbaud);
}
static void
-file_init(const char *fname)
+file_init(const char* fname)
{
db(1, "Opening file...\n");
if ((file_handle = gbfopen(fname, "rb", MYNAME)) == NULL) {
int opt_first_sector_val = atoi(opt_first_sector);
int opt_last_sector_val = atoi(opt_last_sector);
int sectors_read;
- uint8_t *buffer;
+ uint8_t* buffer;
state_init(&st);
buffer = (uint8_t*) xmalloc(SECTOR_SIZE);
#undef MYNAME
#endif
#define MYNAME "miniHomer"
-static char *opt_set_poi_home = NULL; /* set if a "poi" option was used */
-static char *opt_set_poi_car = NULL; /* set if a "poi" option was used */
-static char *opt_set_poi_boat = NULL; /* set if a "poi" option was used */
-static char *opt_set_poi_heart = NULL; /* set if a "poi" option was used */
-static char *opt_set_poi_bar = NULL; /* set if a "poi" option was used */
+static char* opt_set_poi_home = NULL; /* set if a "poi" option was used */
+static char* opt_set_poi_car = NULL; /* set if a "poi" option was used */
+static char* opt_set_poi_boat = NULL; /* set if a "poi" option was used */
+static char* opt_set_poi_heart = NULL; /* set if a "poi" option was used */
+static char* opt_set_poi_bar = NULL; /* set if a "poi" option was used */
arglist_t miniHomer_args[] = {
{ "baud", &opt_dlbaud, "Baud rate used for download", "115200", ARGTYPE_INT, "0", "115200" },
{ "dump-file", &opt_dump_file, "Dump raw data to this file", NULL, ARGTYPE_OUTFILE, ARG_NOMINMAX },
/*
* Names of the POIs on miniHomer
*/
-static const char *poinames[] = {
+static const char* poinames[] = {
"Home", "Car", "Boat", "Heart", "Bar"
};
#define NUMPOI (sizeof poinames/sizeof poinames[0])
-int getPoiByName(char *name)
+int getPoiByName(char* name)
{
unsigned int i;
for (i=0; i<NUMPOI; i++) {
// http://www.mathworks.com/matlabcentral/fileexchange/7942-covert-lat-lon-alt-to-ecef-cartesian
// http://en.wikipedia.org/wiki/Geodetic_system#From_ECEF_to_geodetic
// http://earth-info.nga.mil/GandG/publications/tr8350.2/wgs84fin.pdf
-void lla2ecef(double lat, double lng, double alt, double *ecef_x, double *ecef_y, double *ecef_z)
+void lla2ecef(double lat, double lng, double alt, double* ecef_x, double* ecef_y, double* ecef_z)
{
long double n;
long double a = 6378137.0;
unsigned int poi;
double lat, lng, alt;
double ecef_x, ecef_y, ecef_z;
- waypoint *wpt;
+ waypoint* wpt;
for (poi=0; poi<NUMPOI; poi++) {
MSG_GET_POI[1]=(poi>>8)&0xff;
* -1 in case of errors
* the number of the POI will not be checked - if it is not correct, miniHome will send NACK
*/
-static int miniHomer_set_poi(uint16_t poinum, const char *opt_poi)
+static int miniHomer_set_poi(uint16_t poinum, const char* opt_poi)
{
#define MSG_SET_POI_SIZE (sizeof(uint8_t)+sizeof(uint16_t)+3*sizeof(double)+sizeof(uint8_t))
uint8_t MSG_SET_POI[MSG_SET_POI_SIZE] = {
}
return result;
}
-static const char *mhport;
+static const char* mhport;
static void
-miniHomer_rd_init(const char *fname)
+miniHomer_rd_init(const char* fname)
{
opt_set_location=""; // otherwise it will lead to bus error
skytraq_rd_init(fname); // sets global var serial_handle
static double totalerror = 0;
static double error = 0;
-static char *countopt;
-static char *erroropt;
-static char *xteopt;
-static char *lenopt;
-static char *relopt;
-void (*waypt_del_fnp)(route_head *rte, waypoint *wpt);
+static char* countopt;
+static char* erroropt;
+static char* xteopt;
+static char* lenopt;
+static char* relopt;
+void (*waypt_del_fnp)(route_head* rte, waypoint* wpt);
static
arglist_t routesimple_args[] = {
struct xte {
double distance;
int ordinal;
- struct xte_intermed *intermed;
+ struct xte_intermed* intermed;
};
struct xte_intermed {
- struct xte *xte_rec;
- struct xte_intermed *next;
- struct xte_intermed *prev;
- const waypoint *wpt;
+ struct xte* xte_rec;
+ struct xte_intermed* next;
+ struct xte_intermed* prev;
+ const waypoint* wpt;
};
void
-free_xte(struct xte *xte_rec)
+free_xte(struct xte* xte_rec)
{
xfree(xte_rec->intermed);
}
#define HUGEVAL 2000000000
-static struct xte_intermed *tmpprev = NULL;
+static struct xte_intermed* tmpprev = NULL;
static int xte_count = 0;
-static const route_head *cur_rte = NULL;
-static struct xte *xte_recs = NULL;
+static const route_head* cur_rte = NULL;
+static struct xte* xte_recs = NULL;
void
-routesimple_waypt_pr(const waypoint *wpt)
+routesimple_waypt_pr(const waypoint* wpt)
{
if (!cur_rte) {
return;
}
xte_recs[xte_count].ordinal=xte_count;
- xte_recs[xte_count].intermed = (struct xte_intermed *) xmalloc(sizeof(struct xte_intermed));
+ xte_recs[xte_count].intermed = (struct xte_intermed*) xmalloc(sizeof(struct xte_intermed));
xte_recs[xte_count].intermed->wpt = wpt;
xte_recs[xte_count].intermed->xte_rec = xte_recs+xte_count;
xte_recs[xte_count].intermed->next = NULL;
}
void
-compute_xte(struct xte *xte_rec)
+compute_xte(struct xte* xte_rec)
{
- const waypoint *wpt3 = xte_rec->intermed->wpt;
- const waypoint *wpt1 = NULL;
- const waypoint *wpt2 = NULL;
+ const waypoint* wpt3 = xte_rec->intermed->wpt;
+ const waypoint* wpt1 = NULL;
+ const waypoint* wpt2 = NULL;
double frac, reslat, reslon;
/* if no previous, this is an endpoint and must be preserved. */
if (!xte_rec->intermed->prev) {
int
-compare_xte(const void *a, const void *b)
+compare_xte(const void* a, const void* b)
{
- double distdiff = ((struct xte *)a)->distance -
- ((struct xte *)b)->distance;
- int priodiff = ((struct xte *)a)->intermed->wpt->route_priority -
- ((struct xte *)b)->intermed->wpt->route_priority;
+ double distdiff = ((struct xte*)a)->distance -
+ ((struct xte*)b)->distance;
+ int priodiff = ((struct xte*)a)->intermed->wpt->route_priority -
+ ((struct xte*)b)->intermed->wpt->route_priority;
- if (HUGEVAL == ((struct xte *)a)->distance) {
+ if (HUGEVAL == ((struct xte*)a)->distance) {
return -1;
}
- if (HUGEVAL == ((struct xte *)b)->distance) {
+ if (HUGEVAL == ((struct xte*)b)->distance) {
return 1;
}
}
void
-routesimple_head(const route_head *rte)
+routesimple_head(const route_head* rte)
{
cur_rte = NULL;
/* build array of XTE/wpt xref records */
return;
}
- xte_recs = (struct xte *) xcalloc(rte->rte_waypt_ct, sizeof(struct xte));
+ xte_recs = (struct xte*) xcalloc(rte->rte_waypt_ct, sizeof(struct xte));
cur_rte = rte;
}
void
-shuffle_xte(struct xte *xte_rec)
+shuffle_xte(struct xte* xte_rec)
{
struct xte tmp_xte;
while (xte_rec > xte_recs && compare_xte(xte_rec, xte_rec-1) < 0) {
}
void
-routesimple_tail(const route_head *rte)
+routesimple_tail(const route_head* rte)
{
int i;
if (!cur_rte) {
totalerror += xte_recs[i].distance;
}
}
- (*waypt_del_fnp)((route_head *)(void *)rte,
- (waypoint *)(void *)(xte_recs[i].intermed->wpt));
- waypt_free((waypoint *)(void *)(xte_recs[i].intermed->wpt));
+ (*waypt_del_fnp)((route_head*)(void*)rte,
+ (waypoint*)(void*)(xte_recs[i].intermed->wpt));
+ waypt_free((waypoint*)(void*)(xte_recs[i].intermed->wpt));
if (xte_recs[i].intermed->prev) {
xte_recs[i].intermed->prev->next = xte_recs[i].intermed->next;
}
void
-routesimple_init(const char *args)
+routesimple_init(const char* args)
{
count = 0;
fatal(MYNAME ": You may specify only one of crosstrack, length, or relative.\n");
}
if (!xteopt && !lenopt && !relopt) {
- xteopt = (char *) "";
+ xteopt = (char*) "";
}
if (countopt) {
sort_mode_ sort_mode = sm_shortname; /* How are we sorting these? */
-static char *opt_sm_gcid, *opt_sm_shortname, *opt_sm_description, *opt_sm_time;
+static char* opt_sm_gcid, *opt_sm_shortname, *opt_sm_description, *opt_sm_time;
static
arglist_t sort_args[] = {
};
static int
-sort_comp(const queue * a, const queue * b)
+sort_comp(const queue* a, const queue* b)
{
- const waypoint *x1 = (waypoint *)a;
- const waypoint *x2 = (waypoint *)b;
+ const waypoint* x1 = (waypoint*)a;
+ const waypoint* x2 = (waypoint*)b;
switch (sort_mode) {
case sm_gcid:
}
void
-sort_init(const char *args)
+sort_init(const char* args)
{
if (opt_sm_gcid) {
sort_mode = sm_gcid;
#define MYNAME "Stack filter"
-static char *opt_push = NULL;
-static char *opt_copy = NULL;
-static char *opt_pop = NULL;
-static char *opt_append = NULL;
-static char *opt_discard = NULL;
-static char *opt_replace = NULL;
-static char *opt_swap = NULL;
-static char *opt_depth = NULL;
-static char *nowarn = NULL;
+static char* opt_push = NULL;
+static char* opt_copy = NULL;
+static char* opt_pop = NULL;
+static char* opt_append = NULL;
+static char* opt_discard = NULL;
+static char* opt_replace = NULL;
+static char* opt_swap = NULL;
+static char* opt_depth = NULL;
+static char* nowarn = NULL;
static int warnings_enabled = 1;
static int swapdepth = 0;
unsigned int waypt_ct;
int route_count;
int track_count;
- struct stack_elt *next;
-} *stack = NULL;
+ struct stack_elt* next;
+}* stack = NULL;
void
stackfilt_process(void)
{
- struct stack_elt *tmp_elt = NULL;
- queue *elem = NULL;
- queue *tmp = NULL;
+ struct stack_elt* tmp_elt = NULL;
+ queue* elem = NULL;
+ queue* tmp = NULL;
queue tmp_queue;
unsigned int tmp_count;
if (opt_push) {
- tmp_elt = (struct stack_elt *)xmalloc(sizeof(struct stack_elt));
+ tmp_elt = (struct stack_elt*)xmalloc(sizeof(struct stack_elt));
QUEUE_MOVE(&(tmp_elt->waypts), &waypt_head);
tmp_elt->waypt_ct = waypt_count();
stack = tmp_elt;
if (opt_copy) {
QUEUE_FOR_EACH(&(stack->waypts), elem, tmp) {
- waypt_add(waypt_dupe((waypoint *)elem));
+ waypt_add(waypt_dupe((waypoint*)elem));
}
}
}
if (opt_append) {
QUEUE_FOR_EACH(&(stack->waypts), elem, tmp) {
- waypt_add((waypoint *)elem);
+ waypt_add((waypoint*)elem);
}
route_append(&(stack->routes));
route_flush(&(stack->routes));
}
void
-stackfilt_init(const char *args)
+stackfilt_init(const char* args)
{
int invalid = 0;
void
stackfilt_exit(void)
{
- struct stack_elt *tmp_elt = NULL;
+ struct stack_elt* tmp_elt = NULL;
if (warnings_enabled && stack) {
warning(MYNAME " Warning: leftover stack entries; "
sdf_custom
} sdf_section_e;
-static gbfile *fin, *fout;
+static gbfile* fin, *fout;
static int lineno;
static int datum;
static int filetype;
-static route_head *route;
+static route_head* route;
static queue trackpts;
-static char *rte_name;
-static char *rte_desc;
+static char* rte_name;
+static char* rte_desc;
-static waypoint *trkpt_out;
-static route_head *trk_out;
+static waypoint* trkpt_out;
+static route_head* trk_out;
static double trkpt_dist;
static double minalt, maxalt, maxspeed;
/* placeholders for options */
-static char *opt_route_index;
+static char* opt_route_index;
static int opt_route_index_value;
static
/* ----------------------------------------------------------- */
static void
-parse_header(char *line)
+parse_header(char* line)
{
- char *str;
- char *key = NULL;
- const char *prod = NULL;
+ char* str;
+ char* key = NULL;
+ const char* prod = NULL;
int column = -1;
while ((str = csv_lineparse(line, "=", "", lineno))) {
}
static int
-track_qsort_cb(const void *a, const void *b)
+track_qsort_cb(const void* a, const void* b)
{
- const waypoint *wa = *(waypoint **)a;
- const waypoint *wb = *(waypoint **)b;
+ const waypoint* wa = *(waypoint**)a;
+ const waypoint* wb = *(waypoint**)b;
return wa->GetCreationTime().toTime_t() - wb->GetCreationTime().toTime_t();
}
static void
finalize_tracks(void)
{
- waypoint **list;
+ waypoint** list;
int count = 0;
- queue *elem, *tmp;
+ queue* elem, *tmp;
int index;
- route_head *track = NULL;
+ route_head* track = NULL;
int trackno = 0;
count = 0;
index = 0;
QUEUE_FOR_EACH(&trackpts, elem, tmp) {
- list[index] = (waypoint *)elem;
+ list[index] = (waypoint*)elem;
dequeue(elem);
index++;
}
qsort(list, count, sizeof(*list), track_qsort_cb);
for (index = 0; index < count; index++) {
- waypoint *wpt = list[index];
+ waypoint* wpt = list[index];
if (wpt->wpt_flags.fmt_use == 2) { /* log continued */
track = NULL;
}
}
static void
-parse_point(char *line)
+parse_point(char* line)
{
- char *str;
+ char* str;
int column = -1;
int what = -1; /* -1 = unknown, 0 = tp, 1 = mp, 2 = wp, 3 = ap */
- waypoint *wpt = NULL;
- char *cx;
+ waypoint* wpt = NULL;
+ char* cx;
int hour, min, sec, day, month, year;
year = hour = -1;
/* ----------------------------------------------------------- */
static void
-rd_init(const char *fname)
+rd_init(const char* fname)
{
fin = gbfopen(fname, "r", MYNAME);
static void
data_read(void)
{
- char *buf;
+ char* buf;
sdf_section_e section = sdf_unknown;
while ((buf = gbfgetstr(fin))) {
- char *cin = lrtrim(buf);
+ char* cin = lrtrim(buf);
if ((lineno++ == 0) && fin->unicode) {
cet_convert_init(CET_CHARSET_UTF8, 1);
}
}
if (*cin == '[') {
- char *cend = strchr(++cin, ']');
+ char* cend = strchr(++cin, ']');
if (cend != NULL) {
*cend = '\0';
static void
-calculate(const waypoint *wpt, double *dist, double *speed, double *course,
- double *asc, double *desc)
+calculate(const waypoint* wpt, double* dist, double* speed, double* course,
+ double* asc, double* desc)
{
if (trkpt_out != NULL) {
/* pre-calculation callbacks */
static void
-any_hdr_calc_cb(const route_head *trk)
+any_hdr_calc_cb(const route_head* trk)
{
trkpt_out = NULL;
rte_desc = trk->rte_desc;
}
- trk_out = (route_head *)trk;
+ trk_out = (route_head*)trk;
}
static void
-any_waypt_calc_cb(const waypoint *wpt)
+any_waypt_calc_cb(const waypoint* wpt)
{
double speed, course, dist;
this_time += (wpt->GetCreationTime().toTime_t() - trkpt_out->GetCreationTime().toTime_t());
}
- trkpt_out = (waypoint *)wpt;
+ trkpt_out = (waypoint*)wpt;
}
static void
-any_tlr_calc_cb(const route_head *trk)
+any_tlr_calc_cb(const route_head* trk)
{
if (! this_valid) {
return;
/* write callbacks */
static void
-track_disp_hdr_cb(const route_head *trk)
+track_disp_hdr_cb(const route_head* trk)
{
track_index++;
track_points = 0;
- trk_out = (route_head *)trk;
+ trk_out = (route_head*)trk;
trkpt_out = NULL;
}
static void
-track_disp_wpt_cb(const waypoint *wpt)
+track_disp_wpt_cb(const waypoint* wpt)
{
struct tm tm;
char tbuf[32];
}
if (flag == 1) {
- const char *name = wpt->shortname;
+ const char* name = wpt->shortname;
if (name == NULL) {
name = "Log paused";
}
gbfprintf(fout, "\"MP\",\"%s\"", name);
} else if (flag == 2) {
- const char *name = wpt->shortname;
+ const char* name = wpt->shortname;
if (name == NULL) {
name = "Log continued";
}
gbfprintf(fout, ",0\n");
}
- trkpt_out = (waypoint *)wpt;
+ trkpt_out = (waypoint*)wpt;
}
static void
-track_disp_tlr_cb(const route_head *rte)
+track_disp_tlr_cb(const route_head* rte)
{
trkpt_out = NULL;
}
static void
-route_disp_hdr_cb(const route_head *rte)
+route_disp_hdr_cb(const route_head* rte)
{
route_index++;
this_route_valid = ((opt_route_index_value < 1) || (opt_route_index_value == track_index));
}
static void
-route_disp_wpt_cb(const waypoint *wpt)
+route_disp_wpt_cb(const waypoint* wpt)
{
if (this_route_valid) {
- char *sn;
+ char* sn;
if (global_opts.synthesize_shortnames) {
sn = mkshort_from_wpt(short_h, wpt);
}
static void
-track_disp_custom_cb(const waypoint *wpt)
+track_disp_custom_cb(const waypoint* wpt)
{
if (wpt->GetCreationTime().isValid() && (wpt->altitude != unknown_alt)) {
gbfprintf(fout, "%d,%.f\n", (int)(wpt->GetCreationTime().toTime_t() - start_time), wpt->altitude);
}
static void
-wr_init(const char *fname)
+wr_init(const char* fname)
{
fout = gbfopen(fname, "w", MYNAME);
short_h = mkshort_new_handle();
#include <stdio.h>
#include <stdlib.h>
-static gbfile *fin, *fout;
-static route_head *track, *route;
-static waypoint *wpt;
+static gbfile* fin, *fout;
+static route_head* track, *route;
+static waypoint* wpt;
static short_handle short_h;
#define MYNAME "STMwpp"
static int track_num;
static int what;
-static char *index_opt = NULL;
+static char* index_opt = NULL;
static
arglist_t stmwpp_args[] = {
static void
-stmwpp_rd_init(const char *fname)
+stmwpp_rd_init(const char* fname)
{
fin = gbfopen(fname, "rb", MYNAME);
track = NULL;
static void
stmwpp_data_read(void)
{
- char *buff;
+ char* buff;
int line = 0;
what = STM_NOTHING;
buff = gbfgetstr(fin);
- buff = (buff == NULL) ? (char *) "" : buff;
+ buff = (buff == NULL) ? (char*) "" : buff;
if (case_ignore_strncmp(buff, "Datum,WGS 84,WGS 84,", 20) != 0) {
fatal(MYNAME ": Invalid GPS datum or not \"WaypointPlus\"\" file!\n");
}
while ((buff = gbfgetstr(fin))) {
- char *c;
+ char* c;
int column = -1;
struct tm time;
}
static void
-stmwpp_rw_init(const char *fname)
+stmwpp_rw_init(const char* fname)
{
fout = gbfopen(fname, "wb", MYNAME);
short_h = mkshort_new_handle();
}
static void
-stmwpp_track_hdr(const route_head *track)
+stmwpp_track_hdr(const route_head* track)
{
track_num++;
}
stmwpp_write_double(const double val)
{
char buff[64];
- char *c;
+ char* c;
c = buff + snprintf(buff, sizeof(buff), "%3.7f", val);
while (*--c == '0') {
}
static void
-stmwpp_waypt_cb(const waypoint *wpt)
+stmwpp_waypt_cb(const waypoint* wpt)
{
char cdate[16], ctime[16];
struct tm tm;
snprintf(ctime, sizeof(ctime), "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec);
switch (what) {
- char *sn;
+ char* sn;
case STM_WAYPT:
case STM_RTEPT:
#ifdef __cplusplus
extern "C" {
#endif
-extern char* strptime(const char*, const char*, struct tm*);
+ extern char* strptime(const char*, const char*, struct tm*);
#ifdef __cplusplus
}
#endif
#define MYNAME "subrip"
-static char * opt_videotime;
-static char * opt_gpstime;
-static char * opt_gpsdate;
+static char* opt_videotime;
+static char* opt_gpstime;
+static char* opt_gpsdate;
static time_t time_offset;
static int stnum;
-static gbfile *fout;
-static const waypoint * prevwpp;
+static gbfile* fout;
+static const waypoint* prevwpp;
/* internal helper functions */
static time_t
-sync_time(time_t arg_gpstime, char * arg_videotime)
+sync_time(time_t arg_gpstime, char* arg_videotime)
{
static time_t videotime_t;
- static struct tm * ptm_video;
+ static struct tm* ptm_video;
static time_t result;
videotime_t = 0;
subrip_write_duration(time_t starttime, time_t endtime)
{
/* Writes start and end time for subtitle display to file. */
- struct tm * tmptime;
+ struct tm* tmptime;
tmptime = gmtime(&starttime);
gbfprintf(fout, "%02d:%02d:%02d,000 --> ", tmptime->tm_hour, tmptime->tm_min, tmptime->tm_sec);
subrip_write_time(time_t arg_time)
{
/* Writes a timestamp to file. */
- struct tm * tmptime;
+ struct tm* tmptime;
tmptime = gmtime(&arg_time);
gbfprintf(fout, "%02d:%02d:%02d", tmptime->tm_hour, tmptime->tm_min, tmptime->tm_sec);
}
static void
-subrip_prevwp_pr(const waypoint *waypointp)
+subrip_prevwp_pr(const waypoint* waypointp)
{
/* Now that we have the next waypoint, we can write out the subtitle for
* the previous one.
/* callback functions */
static void
-subrip_trkpt_pr(const waypoint *waypointp)
+subrip_trkpt_pr(const waypoint* waypointp)
{
/*
* To determine the duration of the subtitle, we need the timestamp of the
/* global callback (exported) functions */
static void
-subrip_wr_init(const char *fname)
+subrip_wr_init(const char* fname)
{
time_t gpstime_t;
- struct tm * ptm_gps;
+ struct tm* ptm_gps;
stnum = 1;
};
static void
-swapdata_cb(const waypoint *ref)
+swapdata_cb(const waypoint* ref)
{
- waypoint *wpt = (waypoint *)ref;
+ waypoint* wpt = (waypoint*)ref;
double x;
x = wpt->latitude;
#include "defs.h"
#include "xmlgeneric.h"
-static waypoint *wpt_tmp;
+static waypoint* wpt_tmp;
static int item_count;
static int waypoints;
static double version;
-static route_head *route = NULL;
+static route_head* route = NULL;
-static char *routevia = NULL;
+static char* routevia = NULL;
static arglist_t tef_xml_args[] = {
{
#define MYNAME "TourExchangeFormat"
-static char *
-trimmed_strdup(const char *str)
+static char*
+trimmed_strdup(const char* str)
{
- char *c1, *c2, *res;
+ char* c1, *c2, *res;
c1 = xstrdup(str);
c2 = lrtrim(c1);
*/
void
-tef_start(const char *args, const QXmlStreamAttributes* attrv)
+tef_start(const char* args, const QXmlStreamAttributes* attrv)
{
bool valid = false;
- foreach (QXmlStreamAttribute attr, *attrv) {
+ foreach(QXmlStreamAttribute attr, *attrv) {
if (attr.name().compare("Comment", Qt::CaseInsensitive) == 0) {
if (attr.value().compare("TourExchangeFormat", Qt::CaseInsensitive) == 0) {
valid = true;
*/
static void
-tef_header(const char *args, const QXmlStreamAttributes* attrv)
+tef_header(const char* args, const QXmlStreamAttributes* attrv)
{
route = route_head_alloc();
- foreach (QXmlStreamAttribute attr, *attrv) {
+ foreach(QXmlStreamAttribute attr, *attrv) {
if (attr.name().compare("Name", Qt::CaseInsensitive) == 0) {
route->rte_name = trimmed_strdup(attr.value().toString().toUtf8().constData());
} else if (attr.name().compare("Software", Qt::CaseInsensitive) == 0) {
}
static void
-tef_list_start(const char *args, const QXmlStreamAttributes* attrv)
+tef_list_start(const char* args, const QXmlStreamAttributes* attrv)
{
if (attrv->hasAttribute("ItemCount")) {
item_count = attrv->value("ItemCount").toString().toUInt();
* should be "Wittlicher Strasse (L34)" for the example above
*/
-static char *
-fix_notes(const char *name, char *notes)
+static char*
+fix_notes(const char* name, char* notes)
{
- const char *cleft, *cright, *cback;
- char *ctmp;
+ const char* cleft, *cright, *cback;
+ char* ctmp;
if ((! name) || (! notes)) {
return notes;
if (route != NULL) {
if ((via != 0) || (routevia == NULL)) {
- waypoint *wpt = waypt_dupe(wpt_tmp);
+ waypoint* wpt = waypt_dupe(wpt_tmp);
route_add_wpt(route, wpt);
}
}
}
static void
-tef_item_end(const char *args, const QXmlStreamAttributes* unused)
+tef_item_end(const char* args, const QXmlStreamAttributes* unused)
{
waypoint_final();
}
static void
-tef_list_end(const char *args, const QXmlStreamAttributes* unused)
+tef_list_end(const char* args, const QXmlStreamAttributes* unused)
{
waypoint_final();
if (waypoints != item_count)
}
static void
-tef_item_start(const char *args, const QXmlStreamAttributes* attrv)
+tef_item_start(const char* args, const QXmlStreamAttributes* attrv)
{
waypoints++;
wpt_tmp->wpt_flags.fmt_use ++;
}
- foreach (QXmlStreamAttribute attr, *attrv) {
+ foreach(QXmlStreamAttribute attr, *attrv) {
QString attrstr = attr.value().toString();
QByteArray attrtext = attrstr.toUtf8();
attr.value().compare("true", Qt::CaseInsensitive) == 0) {
wpt_tmp->wpt_flags.fmt_use = 1; /* only a flag */
- /* new in TEF V2 */
+ /* new in TEF V2 */
} else if (attr.name().compare("Instruction", Qt::CaseInsensitive) == 0) {
wpt_tmp->description = trimmed_strdup(attrtext.constData());
} else if (attr.name().compare("Altitude", Qt::CaseInsensitive) == 0) {
}
static void
-tef_point(const char *args, const QXmlStreamAttributes* attrv)
+tef_point(const char* args, const QXmlStreamAttributes* attrv)
{
if (!wpt_tmp) {
return;
}
static void
-tef_xml_rd_init(const char *fname)
+tef_xml_rd_init(const char* fname)
{
wpt_tmp = NULL;
waypoints = 0;
#include "jeeps/gpsmath.h"
#include <ctype.h>
-static gbfile *file_out;
+static gbfile* file_out;
static short_handle mkshort_handle;
-static char *suppresssep = NULL;
-static char *txt_encrypt = NULL;
-static char *includelogs = NULL;
-static char *degformat = NULL;
-static char *altunits = NULL;
-static char *split_output = NULL;
+static char* suppresssep = NULL;
+static char* txt_encrypt = NULL;
+static char* includelogs = NULL;
+static char* degformat = NULL;
+static char* altunits = NULL;
+static char* split_output = NULL;
static int waypoint_count;
-static char *output_name;
+static char* output_name;
#define MYNAME "TEXT"
static void
-wr_init(const char *fname)
+wr_init(const char* fname)
{
waypoint_count = 0;
output_name = xstrdup(fname);
}
static void
-text_disp(const waypoint *wpt)
+text_disp(const waypoint* wpt)
{
int latint, lonint;
char tbuf[1024];
int32_t utmz;
double utme, utmn;
char utmzc;
- char *tmpout1, *tmpout2;
- char *altout;
- fs_xml *fs_gpx;
+ char* tmpout1, *tmpout2;
+ char* altout;
+ fs_xml* fs_gpx;
waypoint_count++;
if (split_output) {
- char *thisfname;
+ char* thisfname;
xasprintf(&thisfname, "%s%d", output_name, waypoint_count);
file_out = gbfopen(thisfname, "w", MYNAME);
}
if (wpt->altitude != unknown_alt) {
xasprintf(&altout, " alt:%d", (int)((altunits[0]=='f')?METERS_TO_FEET(wpt->altitude):wpt->altitude));
} else {
- altout = (char *) "";
+ altout = (char*) "";
}
xasprintf(&tmpout2, "%s (%d%c %6.0f %7.0f)%s", tmpout1, utmz, utmzc, utme, utmn, altout);
gbfprintf(file_out, "%-16s %59s\n",
(int)(wpt->gc_data->diff / 10), (wpt->gc_data->diff%10)?".5":"",
(int)(wpt->gc_data->terr / 10), (wpt->gc_data->terr%10)?".5":"");
if (!wpt->gc_data->desc_short.utfstring.isEmpty()) {
- char *stripped_html = strip_html(&wpt->gc_data->desc_short);
+ char* stripped_html = strip_html(&wpt->gc_data->desc_short);
gbfprintf(file_out, "\n%s\n", stripped_html);
xfree(stripped_html);
}
if (!wpt->gc_data->desc_long.utfstring.isEmpty()) {
- char *stripped_html = strip_html(&wpt->gc_data->desc_long);
+ char* stripped_html = strip_html(&wpt->gc_data->desc_long);
gbfprintf(file_out, "\n%s\n", stripped_html);
xfree(stripped_html);
}
if (!wpt->gc_data->hint.isEmpty()) {
- char *hint = NULL;
+ char* hint = NULL;
if (txt_encrypt) {
hint = rot13(wpt->gc_data->hint);
} else {
fs_gpx = NULL;
if (includelogs) {
- fs_gpx = (fs_xml *)fs_chain_find(wpt->fs, FS_GPX);
+ fs_gpx = (fs_xml*)fs_chain_find(wpt->fs, FS_GPX);
}
if (fs_gpx && fs_gpx->tag) {
- xml_tag *root = fs_gpx->tag;
- xml_tag *curlog = NULL;
- xml_tag *logpart = NULL;
+ xml_tag* root = fs_gpx->tag;
+ xml_tag* curlog = NULL;
+ xml_tag* logpart = NULL;
curlog = xml_findfirst(root, "groundspeak:log");
while (curlog) {
time_t logtime = 0;
- struct tm *logtm = NULL;
+ struct tm* logtm = NULL;
gbfprintf(file_out, "\n");
logpart = xml_findfirst(curlog, "groundspeak:type");
logpart = xml_findfirst(curlog, "groundspeak:log_wpt");
if (logpart) {
- char *coordstr = NULL;
+ char* coordstr = NULL;
double lat = 0;
double lon = 0;
coordstr = xml_attribute(logpart, "lat");
logpart = xml_findfirst(curlog, "groundspeak:text");
if (logpart) {
- char *encstr = NULL;
- char *s = NULL;
+ char* encstr = NULL;
+ char* s = NULL;
int encoded = 0;
encstr = xml_attribute(logpart, "encoded");
encoded = (toupper(encstr[0]) != 'F');
#include "defs.h"
#include "csv_util.h"
-static gbfile *file_in, *file_out;
+static gbfile* file_in, *file_out;
static short_handle mkshort_handle;
static short_handle mkshort_whandle;
static double maxlat, maxlon, minlat, minlon;
static int rec_cnt;
-static char *nolabels = NULL;
-static char *genurl = NULL;
-static char *suppresswhite = NULL;
-static char *iconismarker = NULL;
-static char *snlen = NULL;
-
-static char *margin = NULL;
-static char *xpixels = NULL;
-static char *ypixels = NULL;
-static char *oldthresh = NULL;
-static char *oldmarker = NULL;
-static char *newmarker = NULL;
-static char *unfoundmarker = NULL;
+static char* nolabels = NULL;
+static char* genurl = NULL;
+static char* suppresswhite = NULL;
+static char* iconismarker = NULL;
+static char* snlen = NULL;
+
+static char* margin = NULL;
+static char* xpixels = NULL;
+static char* ypixels = NULL;
+static char* oldthresh = NULL;
+static char* oldmarker = NULL;
+static char* newmarker = NULL;
+static char* unfoundmarker = NULL;
static int short_length;
static double thresh_days;
* the projection transformations. Some trig geek can finish that.
*/
#if CLICKMAP
-static gbfile *linkf;
-static char *clickmap = NULL;
+static gbfile* linkf;
+static char* clickmap = NULL;
#endif
static void
-rd_init(const char *fname)
+rd_init(const char* fname)
{
file_in = gbfopen(fname, "rb", MYNAME);
mkshort_handle = mkshort_new_handle();
}
static void
-wr_init(const char *fname)
+wr_init(const char* fname)
{
file_out = gbfopen(fname, "w", MYNAME);
thresh_days = strtod(oldthresh, NULL);
double lat,lon;
char desc[100];
char icon[100];
- char *ibuf;
- waypoint *wpt_tmp;
+ char* ibuf;
+ waypoint* wpt_tmp;
int line = 0;
while ((ibuf = gbfgetstr(file_in))) {
}
static void
-tiger_disp(const waypoint *wpt)
+tiger_disp(const waypoint* wpt)
{
QString pin;
double lat = wpt->latitude;
gbfprintf(file_out, "%f,%f:%s", lon, lat, pin.toUtf8().data());
if (!nolabels) {
- char *temp = NULL;
- char *desc = csv_stringclean(wpt->description, ":");
+ char* temp = NULL;
+ char* desc = csv_stringclean(wpt->description, ":");
if (global_opts.synthesize_shortnames) {
temp = desc;
desc = mkshort(mkshort_whandle, desc);
#if CLICKMAP
static void
-map_plot(const waypoint *wpt)
+map_plot(const waypoint* wpt)
{
static int x,y;
waypt_disp_all(tiger_disp);
if (genurl) {
- gbfile *urlf;
+ gbfile* urlf;
urlf = gbfopen(genurl, "w", MYNAME);
latsz = fabs(maxlat - minlat);
#define MYNAME "TMPro"
-static gbfile *file_in, *file_out;
+static gbfile* file_in, *file_out;
static short_handle mkshort_handle;
static void
-rd_init(const char *fname)
+rd_init(const char* fname)
{
file_in = gbfopen(fname, "rb", MYNAME);
}
}
static void
-wr_init(const char *fname)
+wr_init(const char* fname)
{
file_out = gbfopen(fname, "w", MYNAME);
}
static void
data_read(void)
{
- char *buff;
- char *s;
- char *holder;
- waypoint *wpt_tmp;
+ char* buff;
+ char* s;
+ char* holder;
+ waypoint* wpt_tmp;
int i;
int linecount = 0;
}
static void
-tmpro_waypt_pr(const waypoint * wpt)
+tmpro_waypt_pr(const waypoint* wpt)
{
int icon = 1; /* default to "flag" */
int colour = 255; /*default to red */
- char *shortname = NULL;
- char *description = NULL;
+ char* shortname = NULL;
+ char* description = NULL;
if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
if (wpt->description) {
/* Number of characters */
/* 25 6 80 8 8 8 8 8 4 4 128 */
- const char *l = NULL;
+ const char* l = NULL;
if (wpt->HasUrlLink()) {
// Yes, it's lame to allocate/copy here.
UrlLink link = wpt->GetUrlLink();
#define MYNAME "TomTom"
-static gbfile *file_in;
-static gbfile *file_out;
+static gbfile* file_in;
+static gbfile* file_out;
static
arglist_t tomtom_args[] = {
};
static void
-rd_init(const char *fname)
+rd_init(const char* fname)
{
file_in = gbfopen_le(fname, "rb", MYNAME);
}
}
static void
-wr_init(const char *fname)
+wr_init(const char* fname)
{
file_out = gbfopen_le(fname, "wb", MYNAME);
}
/*
* Decode a type 8 compressed record
*/
-char *
-decode_8(int sz, const unsigned char *inbuf)
+char*
+decode_8(int sz, const unsigned char* inbuf)
{
static const char encoding_8[] = "X. SaerionstldchumgpbkfzvACBMPG-";
static const int encoding_8_high[8] = {0x2,0x3,0x4,0x5,0x6,0x7,0xe,0xf};
// Maximally sized for laziness.
- char *rval = (char *) xmalloc(sz * 3 + 1);
- char *out = rval;
+ char* rval = (char*) xmalloc(sz * 3 + 1);
+ char* out = rval;
int i;
for (i = 0; i < sz;) {
}
void
-decode_latlon(double *lat, double *lon)
+decode_latlon(double* lat, double* lon)
{
unsigned char latbuf[3];
unsigned char lonbuf[3];
long recsize;
long x;
long y;
- char *desc;
- waypoint *wpt_tmp;
+ char* desc;
+ waypoint* wpt_tmp;
while (!gbfeof(file_in)) {
rectype = read_char(file_in);
if (rectype == EOF) {
check_recsize(recsize);
x = read_long(file_in);
y = read_long(file_in);
- desc = (char *)xmalloc(recsize - 13);
+ desc = (char*)xmalloc(recsize - 13);
gbfread(desc, recsize-13, 1, file_in);
wpt_tmp = waypt_new();
struct hdr {
- waypoint *wpt;
+ waypoint* wpt;
};
-static int compare_lon(const void *a, const void *b);
+static int compare_lon(const void* a, const void* b);
static
int
-compare_lat(const void *a, const void *b)
+compare_lat(const void* a, const void* b)
{
- const struct hdr *wa = (const struct hdr*) a;
- const struct hdr *wb = (const struct hdr*) b;
+ const struct hdr* wa = (const struct hdr*) a;
+ const struct hdr* wb = (const struct hdr*) b;
double difference = wa->wpt->latitude - wb->wpt->latitude;
if (difference < 0) {
static
int
-compare_lon(const void *a, const void *b)
+compare_lon(const void* a, const void* b)
{
- const struct hdr *wa = (const struct hdr*)a;
- const struct hdr *wb = (const struct hdr*)b;
+ const struct hdr* wa = (const struct hdr*)a;
+ const struct hdr* wb = (const struct hdr*)b;
double difference = wa->wpt->longitude - wb->wpt->longitude;
if (difference < 0) {
#define write_long(f,v) gbfputint32((v),f)
static void
-write_float_as_long(gbfile *file, double value)
+write_float_as_long(gbfile* file, double value)
{
long tmp = (value + 0.500000000001);
write_long(file, tmp);
#define write_string(f,s) gbfputcstr((s),f)
struct blockheader {
- struct hdr *start;
+ struct hdr* start;
long count;
long size;
double minlat;
double maxlat;
double minlon;
double maxlon;
- struct blockheader *ch1;
- struct blockheader *ch2;
+ struct blockheader* ch1;
+ struct blockheader* ch2;
};
static void
-write_blocks(gbfile *f, struct blockheader *blocks)
+write_blocks(gbfile* f, struct blockheader* blocks)
{
int i;
write_char(f, 1);
}
}
-static struct blockheader *
-compute_blocks(struct hdr *start, int count,
+static struct blockheader*
+compute_blocks(struct hdr* start, int count,
double minlon, double maxlon, double minlat, double maxlat) {
- struct blockheader *newblock;
+ struct blockheader* newblock;
- newblock = (struct blockheader *)xcalloc(sizeof(*newblock), 1);
+ newblock = (struct blockheader*)xcalloc(sizeof(*newblock), 1);
newblock->start = start;
newblock->count = count;
newblock->minlon = minlon;
newblock->size = 4 * 5 + 1; /* hdr is 5 longs, 1 char */
if (count < 20) {
int i;
- waypoint *wpt = NULL;
+ waypoint* wpt = NULL;
for (i = 0; i < count; i++) {
newblock->size += 4 * 3 + 1;
}
static void
-free_blocks(struct blockheader *block)
+free_blocks(struct blockheader* block)
{
if (block->ch1) {
free_blocks(block->ch1);
data_write(void)
{
int ct = waypt_count();
- struct hdr *htable, *bh;
- queue *elem, *tmp;
+ struct hdr* htable, *bh;
+ queue* elem, *tmp;
extern queue waypt_head;
- waypoint *waypointp;
+ waypoint* waypointp;
double minlon = 200;
double maxlon = -200;
double minlat = 200;
double maxlat = -200;
- struct blockheader *blocks = NULL;
+ struct blockheader* blocks = NULL;
htable = (struct hdr*) xmalloc(ct * sizeof(*htable));
bh = htable;
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- waypointp = (waypoint *) elem;
+ waypointp = (waypoint*) elem;
bh->wpt = waypointp;
if (waypointp->longitude > maxlon) {
maxlon = waypointp->longitude;
#define MAXTPGSTRINGSIZE 256
#define MAXTPGOUTPUTPINS 65535
-static gbfile *tpg_file_in;
-static gbfile *tpg_file_out;
+static gbfile* tpg_file_in;
+static gbfile* tpg_file_out;
static short_handle mkshort_handle;
-static char *tpg_datum_opt;
+static char* tpg_datum_opt;
static int tpg_datum_idx;
static unsigned int waypt_out_count;
};
static int
-valid_tpg_header(char * header, int len)
+valid_tpg_header(char* header, int len)
{
unsigned char header_bytes[] = { 0xFF, 0xFF, 0x01, 0x00, 0x0D,
0x00, 0x43, 0x54, 0x6F, 0x70,
}
static void
-tpg_rd_init(const char *fname)
+tpg_rd_init(const char* fname)
{
tpg_common_init();
tpg_file_in = gbfopen_le(fname, "rb", MYNAME);
}
static void
-tpg_wr_init(const char *fname)
+tpg_wr_init(const char* fname)
{
tpg_common_init();
tpg_file_out = gbfopen_le(fname, "wb", MYNAME);
tpg_read(void)
{
char buff[MAXTPGSTRINGSIZE + 1];
- waypoint *wpt_tmp;
+ waypoint* wpt_tmp;
double lat, lon, elev;
double amt;
short int pointcount;
}
static void
-tpg_waypt_pr(const waypoint *wpt)
+tpg_waypt_pr(const waypoint* wpt)
{
double lon, lat;
double amt;
short int elev;
char tbuf[64];
char c,ocount;
- char *shortname;
- char *description;
+ char* shortname;
+ char* description;
int i;
/* these unknown 4 are probably point properties (color, icon, etc..) */
}
#define TRACKNAMELENGTH 256
-struct style_info{
+struct style_info {
char name[TRACKNAMELENGTH]; // some huge value
uint8_t color[3]; // keep R/G/B values separate because line_color needs BGR
uint8_t wide;
printf("Unpacking %d track styles...\n",track_style_count);
}
- style_info *styles = (style_info *)xcalloc(track_style_count, sizeof(style_info));
+ style_info* styles = (style_info*)xcalloc(track_style_count, sizeof(style_info));
for (ii = 0; ii < track_style_count; ii++) {
// Topo and web uses rrggbb, also need line_color.bbggrr for KML
for (xx = 0; xx < 3; xx++) {
int col = (int)gbfgetc(tpo_file_in);
- if((col < 0) || (col >255)) {
+ if ((col < 0) || (col >255)) {
col = 0; // assign black if out of range 0x00 to 0xff
}
styles[ii].color[xx] = (uint8_t)col;
// track texture (dashed=1, solid=0) mapped into opacity - not assigned before 2012
track_temp->line_color.opacity = 0xff; // 255
- if(styles[track_style].dash) {
+ if (styles[track_style].dash) {
track_temp->line_color.opacity = 0x50;
}
// Track description
// track_temp->rte_desc = NULL; // pre-2012 default, next line from SRE saves track style as track description
xasprintf(&track_temp->rte_desc, "Style=%s, Width=%d, Dashed=%d, Color=#%s",
- styles[track_style].name, styles[track_style].wide, styles[track_style].dash, rgb);
+ styles[track_style].name, styles[track_style].wide, styles[track_style].dash, rgb);
// Route number
track_temp->rte_num = ii+1;
#undef TRACKF_DBG
-static char *opt_merge = NULL;
-static char *opt_pack = NULL;
-static char *opt_split = NULL;
-static char *opt_sdistance = NULL;
-static char *opt_move = NULL;
-static char *opt_title = NULL;
-static char *opt_start = NULL;
-static char *opt_stop = NULL;
-static char *opt_fix = NULL;
-static char *opt_course = NULL;
-static char *opt_speed = NULL;
-static char *opt_name = NULL;
-static char *opt_seg2trk = NULL;
-static char *opt_trk2seg = NULL;
-static char *opt_segment = NULL;
-static char *opt_faketime = NULL;
-static char *opt_discard = NULL;
+static char* opt_merge = NULL;
+static char* opt_pack = NULL;
+static char* opt_split = NULL;
+static char* opt_sdistance = NULL;
+static char* opt_move = NULL;
+static char* opt_title = NULL;
+static char* opt_start = NULL;
+static char* opt_stop = NULL;
+static char* opt_fix = NULL;
+static char* opt_course = NULL;
+static char* opt_speed = NULL;
+static char* opt_name = NULL;
+static char* opt_seg2trk = NULL;
+static char* opt_trk2seg = NULL;
+static char* opt_segment = NULL;
+static char* opt_faketime = NULL;
+static char* opt_discard = NULL;
static
arglist_t trackfilter_args[] = {
typedef struct trkflt_s {
- route_head *track;
+ route_head* track;
QDateTime first_time;
QDateTime last_time;
} trkflt_t;
-static trkflt_t *track_list = NULL;
+static trkflt_t* track_list = NULL;
static int track_ct = 0;
static int track_pts = 0;
static int timeless_pts = 0;
trackfilter_opt_count(void)
{
int res = 0;
- arglist_t *a = trackfilter_args;
+ arglist_t* a = trackfilter_args;
while (a->argstring) {
if (*a->argval != NULL) {
}
static int
-trackfilter_parse_time_opt(const char *arg)
+trackfilter_parse_time_opt(const char* arg)
{
time_t t0, t1;
int sign = 1;
- char *cin = (char *)arg;
+ char* cin = (char*)arg;
char c;
t0 = t1 = 0;
}
static int
-trackfilter_init_qsort_cb(const void *a, const void *b)
+trackfilter_init_qsort_cb(const void* a, const void* b)
{
- const trkflt_t *ra = (const trkflt_t*) a;
- const trkflt_t *rb = (const trkflt_t*) b;
+ const trkflt_t* ra = (const trkflt_t*) a;
+ const trkflt_t* rb = (const trkflt_t*) b;
const QDateTime dta = ra->first_time;
const QDateTime dtb = rb->first_time;
}
static int
-trackfilter_merge_qsort_cb(const void *a, const void *b)
+trackfilter_merge_qsort_cb(const void* a, const void* b)
{
- const waypoint *wa = *(waypoint **)a;
- const waypoint *wb = *(waypoint **)b;
+ const waypoint* wa = *(waypoint**)a;
+ const waypoint* wb = *(waypoint**)b;
const QDateTime dta = wa->GetCreationTime();
const QDateTime dtb = wb->GetCreationTime();
}
static fix_type
-trackfilter_parse_fix(int *nsats)
+trackfilter_parse_fix(int* nsats)
{
if (!opt_fix) {
return fix_unknown;
}
static void
-trackfilter_fill_track_list_cb(const route_head *track) /* callback for track_disp_all */
+trackfilter_fill_track_list_cb(const route_head* track) /* callback for track_disp_all */
{
int i;
- waypoint *wpt, *prev;
- queue *elem, *tmp;
+ waypoint* wpt, *prev;
+ queue* elem, *tmp;
if (track->rte_waypt_ct == 0) {
- track_del_head((route_head *)track);
+ track_del_head((route_head*)track);
return;
}
if (opt_name != NULL) {
if ((track->rte_name == NULL) ||
(case_ignore_str_match(track->rte_name, opt_name) == 0)) {
- QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) {
- waypoint *wpt = (waypoint *)elem;
- track_del_wpt((route_head *)track, wpt);
+ QUEUE_FOR_EACH((queue*)&track->waypoint_list, elem, tmp) {
+ waypoint* wpt = (waypoint*)elem;
+ track_del_wpt((route_head*)track, wpt);
waypt_free(wpt);
}
- track_del_head((route_head *)track);
+ track_del_head((route_head*)track);
return;
}
}
- track_list[track_ct].track = (route_head *)track;
+ track_list[track_ct].track = (route_head*)track;
i = 0;
prev = NULL;
- QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) {
+ QUEUE_FOR_EACH((queue*)&track->waypoint_list, elem, tmp) {
track_pts++;
- wpt = (waypoint *)elem;
- if (!wpt->creation_time.isValid()) timeless_pts++;
+ wpt = (waypoint*)elem;
+ if (!wpt->creation_time.isValid()) {
+ timeless_pts++;
+ }
if (!(opt_merge && opt_discard) && (need_time != 0) && (!wpt->creation_time.isValid())) {
fatal(MYNAME "-init: Found track point at %f,%f without time!\n",
wpt->latitude, wpt->longitude);
*******************************************************************************/
static void
-trackfilter_split_init_rte_name(route_head *track, const QDateTime dt)
+trackfilter_split_init_rte_name(route_head* track, const QDateTime dt)
{
char buff[128], tbuff[128];
struct tm tm;
}
static void
-trackfilter_pack_init_rte_name(route_head *track, const time_t default_time)
+trackfilter_pack_init_rte_name(route_head* track, const time_t default_time)
{
char buff[128];
if (strchr(opt_title, '%') != NULL) {
struct tm tm;
- waypoint *wpt;
+ waypoint* wpt;
if (track->rte_waypt_ct == 0) {
tm = *localtime(&default_time);
} else {
- wpt = (waypoint *) QUEUE_FIRST((queue *)&track->waypoint_list);
+ wpt = (waypoint*) QUEUE_FIRST((queue*)&track->waypoint_list);
time_t t = wpt->GetCreationTime().toTime_t();
tm = *localtime(&t);
}
fatal(MYNAME "-title: Missing your title!\n");
}
for (i = 0; i < track_ct; i++) {
- route_head *track = track_list[i].track;
+ route_head* track = track_list[i].track;
trackfilter_pack_init_rte_name(track, 0);
}
}
{
int i, j;
trkflt_t prev;
- route_head *master;
+ route_head* master;
for (i = 1, j = 0; i < track_ct; i++, j++) {
prev = track_list[j];
master = track_list[0].track;
for (i = 1; i < track_ct; i++) {
- queue *elem, *tmp;
- route_head *curr = track_list[i].track;
+ queue* elem, *tmp;
+ route_head* curr = track_list[i].track;
- QUEUE_FOR_EACH((queue *)&curr->waypoint_list, elem, tmp) {
- waypoint *wpt = (waypoint *)elem;
+ QUEUE_FOR_EACH((queue*)&curr->waypoint_list, elem, tmp) {
+ waypoint* wpt = (waypoint*)elem;
track_del_wpt(curr, wpt);
track_add_wpt(master, wpt);
}
{
int i, j, dropped;
- queue *elem, *tmp;
- waypoint **buff;
- waypoint *prev, *wpt;
- route_head *master = track_list[0].track;
+ queue* elem, *tmp;
+ waypoint** buff;
+ waypoint* prev, *wpt;
+ route_head* master = track_list[0].track;
if (track_pts-timeless_pts < 1) {
return;
}
- buff = (waypoint **)xcalloc(track_pts-timeless_pts, sizeof(*buff));
+ buff = (waypoint**)xcalloc(track_pts-timeless_pts, sizeof(*buff));
j = 0;
for (i = 0; i < track_ct; i++) { /* put all points into temp buffer */
- route_head *track = track_list[i].track;
- QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) {
- wpt = (waypoint *)elem;
- if(wpt->creation_time.isValid()) {
+ route_head* track = track_list[i].track;
+ QUEUE_FOR_EACH((queue*)&track->waypoint_list, elem, tmp) {
+ wpt = (waypoint*)elem;
+ if (wpt->creation_time.isValid()) {
buff[j++] = waypt_dupe(wpt);
}
track_del_wpt(track, wpt);
static void
trackfilter_split(void)
{
- route_head *curr;
- route_head *master = track_list[0].track;
+ route_head* curr;
+ route_head* master = track_list[0].track;
int count = master->rte_waypt_ct;
- waypoint **buff;
- waypoint *wpt;
- queue *elem, *tmp;
+ waypoint** buff;
+ waypoint* wpt;
+ queue* elem, *tmp;
int i, j;
double interval = -1;
double distance = -1;
trackfilter_split_init_rte_name(master, track_list[0].first_time);
- buff = (waypoint **) xcalloc(count, sizeof(*buff));
+ buff = (waypoint**) xcalloc(count, sizeof(*buff));
i = 0;
- QUEUE_FOR_EACH((queue *)&master->waypoint_list, elem, tmp) {
- wpt = (waypoint *)elem;
+ QUEUE_FOR_EACH((queue*)&master->waypoint_list, elem, tmp) {
+ wpt = (waypoint*)elem;
buff[i++] = wpt;
}
#ifdef TRACKF_DBG
printf(MYNAME ": splitting new track\n");
#endif
- curr = (route_head *) route_head_alloc();
+ curr = (route_head*) route_head_alloc();
trackfilter_split_init_rte_name(curr, buff[j]->GetCreationTime());
track_add_head(curr);
}
trackfilter_move(void)
{
int i;
- queue *elem, *tmp;
- waypoint *wpt;
+ queue* elem, *tmp;
+ waypoint* wpt;
time_t delta;
delta = trackfilter_parse_time_opt(opt_move);
}
for (i = 0; i < track_ct; i++) {
- route_head *track = track_list[i].track;
- QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) {
- wpt = (waypoint *)elem;
+ route_head* track = track_list[i].track;
+ QUEUE_FOR_EACH((queue*)&track->waypoint_list, elem, tmp) {
+ wpt = (waypoint*)elem;
wpt->creation_time += delta;
}
trackfilter_synth(void)
{
int i;
- queue *elem, *tmp;
- waypoint *wpt;
+ queue* elem, *tmp;
+ waypoint* wpt;
double oldlat = -999;
double oldlon = -999;
fix = trackfilter_parse_fix(&nsats);
for (i = 0; i < track_ct; i++) {
- route_head *track = track_list[i].track;
+ route_head* track = track_list[i].track;
first = 1;
- QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) {
- wpt = (waypoint *)elem;
+ QUEUE_FOR_EACH((queue*)&track->waypoint_list, elem, tmp) {
+ wpt = (waypoint*)elem;
if (opt_fix) {
wpt->fix = fix;
if (wpt->sat == 0) {
*******************************************************************************/
static time_t
-trackfilter_range_check(const char *timestr)
+trackfilter_range_check(const char* timestr)
{
int i;
char fmt[20];
char c;
- char *cin;
+ char* cin;
struct tm time;
i = 0;
strncpy(fmt, "00000101000000", sizeof(fmt));
- cin = (char *)timestr;
+ cin = (char*)timestr;
while ((c = *cin++)) {
if (fmt[i] == '\0') {
trackfilter_range(void) /* returns number of track points left after filtering */
{
time_t start, stop;
- queue *elem, *tmp;
+ queue* elem, *tmp;
int i, dropped, inside = 0;
if (opt_start != 0) {
dropped = inside = 0;
for (i = 0; i < track_ct; i++) {
- route_head *track = track_list[i].track;
+ route_head* track = track_list[i].track;
- QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) {
- waypoint *wpt = (waypoint *)elem;
+ QUEUE_FOR_EACH((queue*)&track->waypoint_list, elem, tmp) {
+ waypoint* wpt = (waypoint*)elem;
if (wpt->creation_time.isValid()) {
inside = ((wpt->GetCreationTime().toTime_t() >= start) && (wpt->GetCreationTime().toTime_t() <= stop));
}
int i;
for (i = 0; i < track_ct; i++) {
- queue *elem, *tmp;
- route_head *src = track_list[i].track;
- route_head *dest = NULL;
- route_head *insert_point = src;
+ queue* elem, *tmp;
+ route_head* src = track_list[i].track;
+ route_head* dest = NULL;
+ route_head* insert_point = src;
int trk_seg_num = 1, first = 1;
- QUEUE_FOR_EACH((queue *)&src->waypoint_list, elem, tmp) {
- waypoint *wpt = (waypoint *)elem;
+ QUEUE_FOR_EACH((queue*)&src->waypoint_list, elem, tmp) {
+ waypoint* wpt = (waypoint*)elem;
if (wpt->wpt_flags.new_trkseg && !first) {
dest = route_head_alloc();
trackfilter_trk2seg(void)
{
int i, first;
- route_head *master;
+ route_head* master;
master = track_list[0].track;
for (i = 1; i < track_ct; i++) {
- queue *elem, *tmp;
- route_head *curr = track_list[i].track;
+ queue* elem, *tmp;
+ route_head* curr = track_list[i].track;
first = 1;
- QUEUE_FOR_EACH((queue *)&curr->waypoint_list, elem, tmp) {
- waypoint *wpt = (waypoint *)elem;
+ QUEUE_FOR_EACH((queue*)&curr->waypoint_list, elem, tmp) {
+ waypoint* wpt = (waypoint*)elem;
int orig_new_trkseg = wpt->wpt_flags.new_trkseg;
} faketime_t;
static faketime_t
-trackfilter_faketime_check(const char *timestr)
+trackfilter_faketime_check(const char* timestr)
{
int i, j;
char fmtstart[20];
char fmtstep[20];
char c;
- const char *cin;
+ const char* cin;
struct tm time;
int timeparse = 1;
faketime_t result;
{
faketime_t faketime;
- queue *elem, *tmp;
+ queue* elem, *tmp;
int i, dropped, inside = 0;
if (opt_faketime != 0) {
dropped = inside = 0;
for (i = 0; i < track_ct; i++) {
- route_head *track = track_list[i].track;
+ route_head* track = track_list[i].track;
- QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) {
- waypoint *wpt = (waypoint *)elem;
+ QUEUE_FOR_EACH((queue*)&track->waypoint_list, elem, tmp) {
+ waypoint* wpt = (waypoint*)elem;
if (opt_faketime != 0 && (!wpt->creation_time.isValid() || faketime.force)) {
wpt->creation_time = QDateTime::fromTime_t(faketime.start);
}
static int
-trackfilter_points_are_same(const waypoint *wpta, const waypoint *wptb)
+trackfilter_points_are_same(const waypoint* wpta, const waypoint* wptb)
{
// We use a simpler (non great circle) test for lat/lon here as this
// is used for keeping the 'bookends' of non-moving points.
}
static void
-trackfilter_segment_head(const route_head *rte)
+trackfilter_segment_head(const route_head* rte)
{
- queue *elem, *tmp;
+ queue* elem, *tmp;
double avg_dist = 0;
int index = 0;
- waypoint *prev_wpt = NULL;
+ waypoint* prev_wpt = NULL;
// Consider tossing trackpoints closer than this in radians.
// (Empirically determined; It's a few dozen feet.)
const double ktoo_close = 0.000005;
QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
- waypoint *wpt = (waypoint *)elem;
+ waypoint* wpt = (waypoint*)elem;
if (index > 0) {
double cur_dist = gcdist(RAD(prev_wpt->latitude),
RAD(prev_wpt->longitude),
}
if (cur_dist < ktoo_close) {
- if (wpt != (waypoint *) QUEUE_LAST(&rte->waypoint_list)) {
- waypoint *next_wpt = (waypoint *) QUEUE_NEXT(&wpt->Q);
+ if (wpt != (waypoint*) QUEUE_LAST(&rte->waypoint_list)) {
+ waypoint* next_wpt = (waypoint*) QUEUE_NEXT(&wpt->Q);
if (trackfilter_points_are_same(prev_wpt, wpt) &&
trackfilter_points_are_same(wpt, next_wpt)) {
- track_del_wpt((route_head *)rte, wpt);
+ track_del_wpt((route_head*)rte, wpt);
continue;
}
}
*******************************************************************************/
static void
-trackfilter_init(const char *args)
+trackfilter_init(const char* args)
{
int count = track_count();
#define MYNAME "transform"
static char current_target;
-static route_head *current_trk;
-static route_head *current_rte;
+static route_head* current_trk;
+static route_head* current_rte;
-static char *opt_routes, *opt_tracks, *opt_waypts, *opt_delete;
+static char* opt_routes, *opt_tracks, *opt_waypts, *opt_delete;
static
arglist_t transform_args[] = {
static void
transform_waypoints(void)
{
- route_head *rte;
+ route_head* rte;
rte = route_head_alloc();
switch (current_target) {
#if NEWQ
foreach(waypoint* wpt, waypt_list) {
#else
- queue *elem, *tmp;
+ queue* elem, *tmp;
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- waypoint *wpt = (waypoint *) elem;
+ waypoint* wpt = (waypoint*) elem;
#endif
wpt = waypt_dupe(wpt);
}
static void
-transform_rte_disp_hdr_cb(const route_head *rte)
+transform_rte_disp_hdr_cb(const route_head* rte)
{
if (current_target == 'T') {
current_trk = route_head_alloc();
}
static void
-transform_trk_disp_hdr_cb(const route_head *trk)
+transform_trk_disp_hdr_cb(const route_head* trk)
{
if (current_target == 'R') {
current_rte = route_head_alloc();
}
static void
-transform_any_disp_wpt_cb(const waypoint *wpt)
+transform_any_disp_wpt_cb(const waypoint* wpt)
{
- waypoint *temp = waypt_dupe(wpt);
+ waypoint* temp = waypt_dupe(wpt);
if (current_target == 'R') {
route_add_wpt(current_rte, temp);
} else if (current_target == 'T') {
*******************************************************************************/
static void
-transform_init(const char *args)
+transform_init(const char* args)
{
}
#define unicsv_unknown 1e25
typedef struct {
- const char *name;
+ const char* name;
field_e type;
uint32_t options;
} field_t;
{ NULL, fld_terminator, 0 }
};
-static field_e *unicsv_fields_tab;
+static field_e* unicsv_fields_tab;
static int unicsv_fields_tab_ct;
static double unicsv_altscale, unicsv_depthscale, unicsv_proximityscale
;
-static const char *unicsv_fieldsep;
-static gbfile *fin, *fout;
+static const char* unicsv_fieldsep;
+static gbfile* fin, *fout;
static gpsdata_type unicsv_data_type;
-static route_head *unicsv_track, *unicsv_route;
+static route_head* unicsv_track, *unicsv_route;
static char unicsv_outp_flags[(fld_terminator + 8) / 8];
static grid_type unicsv_grid_idx;
static int unicsv_datum_idx;
-static char *opt_datum, *opt_grid, *opt_utc, *opt_filename, *opt_format, *opt_prec;
+static char* opt_datum, *opt_grid, *opt_utc, *opt_filename, *opt_format, *opt_prec;
static int unicsv_waypt_ct;
static char unicsv_detect;
static int llprec;
/* here we only need a simple yes(0) or no(1) */
static int
-unicsv_strrcmp(const char *s1, const char *s2)
+unicsv_strrcmp(const char* s1, const char* s2)
{
int l1, l2;
}
static int
-unicsv_parse_gc_id(const char *str)
+unicsv_parse_gc_id(const char* str)
{
int res = 0;
// static int unicsv_parse_time(const char *str, int *msec, time_t *date);
static time_t
-unicsv_parse_date(const char *str, int *consumed)
+unicsv_parse_date(const char* str, int* consumed)
{
int p1, p2, p3, ct;
char sep[2];
}
static time_t
-unicsv_parse_time(const char *str, int *msec, time_t *date)
+unicsv_parse_time(const char* str, int* msec, time_t* date)
{
int hour, min, ct, sec;
int consumed = 0;
#ifdef UNICSV_GC_READY
static status_type
-unicsv_parse_status(const char *str)
+unicsv_parse_status(const char* str)
{
if ((case_ignore_strcmp(str, "true") == 0) ||
(case_ignore_strcmp(str, "yes") == 0) ||
#ifdef UNICSV_GC_READY
static QDateTime
-unicsv_adjust_time(const time_t time, time_t *date)
+unicsv_adjust_time(const time_t time, time_t* date)
{
time_t res = time;
if (date) {
#endif
static char
-unicsv_compare_fields(char *s, const field_t *f)
+unicsv_compare_fields(char* s, const field_t* f)
{
- char *name = (char *)f->name;
- char *test = s;
+ char* name = (char*)f->name;
+ char* test = s;
char result;
if (!(f->options & STR_CASE)) {
if ((! result) && (strchr(test, ' ') != NULL)) {
/* replace ' ' with '_' and try again */
- char *tmp = gstrsub(test, " ", "_");
+ char* tmp = gstrsub(test, " ", "_");
result = unicsv_compare_fields(tmp, f);
xfree(tmp);
}
if ((! result) && (strchr(test, '-') != NULL)) {
/* replace '-' with '_' and try again */
- char *tmp = gstrsub(test, "-", "_");
+ char* tmp = gstrsub(test, "-", "_");
result = unicsv_compare_fields(tmp, f);
xfree(tmp);
}
static void
-unicsv_fondle_header(char *ibuf)
+unicsv_fondle_header(char* ibuf)
{
- char *s;
- char *buf = NULL;
+ char* s;
+ char* buf = NULL;
int i, column;
- const cet_cs_vec_t *ascii = &cet_cs_vec_ansi_x3_4_1968; /* us-ascii */
+ const cet_cs_vec_t* ascii = &cet_cs_vec_ansi_x3_4_1968; /* us-ascii */
/* Convert the entire header to lower case for convenience.
* If we see a tab in that header, we decree it to be tabsep.
column = -1;
while ((s = csv_lineparse(ibuf, unicsv_fieldsep, "\"", 0))) {
- field_t *f = &fields_def[0];
+ field_t* f = &fields_def[0];
ibuf = NULL;
column++;
}
static void
-unicsv_rd_init(const char *fname)
+unicsv_rd_init(const char* fname)
{
- char *c;
+ char* c;
unicsv_altscale = 1.0;
unicsv_depthscale = 1.0;
unicsv_proximityscale = 1.0;
}
static void
-unicsv_parse_one_line(char *ibuf)
+unicsv_parse_one_line(char* ibuf)
{
- char *s;
- waypoint *wpt = NULL;
+ char* s;
+ waypoint* wpt = NULL;
int column;
int utm_zone = -9999;
double utm_easting = 0;
time_t date = -1, time = -1;
int msec = -1;
char is_localtime = 0;
- garmin_fs_t *gmsd;
+ garmin_fs_t* gmsd;
double d;
struct tm ymd;
int src_datum = unicsv_datum_idx;
int ns = 1;
int ew = 1;
#ifdef UNICSV_GC_READY
- geocache_data *gc_data = NULL;
+ geocache_data* gc_data = NULL;
#endif
wpt = waypt_new();
wpt->latitude = unicsv_unknown;
break;
case fld_url: {
-qDebug() << s;
+ qDebug() << s;
UrlLink l(s);
wpt->AddUrlLink(l);
- }
- break;
+ }
+ break;
case fld_altitude:
if (parse_distance(s, &d, unicsv_altscale, MYNAME)) {
gmsd = GMSD_FIND(wpt);
if (! gmsd) {
gmsd = garmin_fs_alloc(-1);
- fs_chain_add(&wpt->fs, (format_specific_data *) gmsd);
+ fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
}
switch (unicsv_fields_tab[column]) {
case fld_garmin_city:
static void
unicsv_rd(void)
{
- char *buff;
+ char* buff;
if (unicsv_fieldsep == NULL) {
return;
/* =========================================================================== */
static void
-unicsv_fatal_outside(const waypoint *wpt)
+unicsv_fatal_outside(const waypoint* wpt)
{
gbfprintf(fout, "#####\n");
fatal(MYNAME ": %s (%s) is outside of convertable area of grid \"%s\"!\n",
}
static void
-unicsv_print_str(const char *str)
+unicsv_print_str(const char* str)
{
if (str && *str) {
- char *cout, *cx;
+ char* cout, *cx;
cout = strenquote(str, UNICSV_QUOT_CHAR);
static void
unicsv_print_str(const QString& s)
{
- char *t = xstrdup(s.toUtf8().data());
+ char* t = xstrdup(s.toUtf8().data());
unicsv_print_str(t);
xfree(t);
}
#define FIELD_USED(a) (gb_getbit(&unicsv_outp_flags, a))
static void
-unicsv_waypt_enum_cb(const waypoint *wpt)
+unicsv_waypt_enum_cb(const waypoint* wpt)
{
- const char *shortname;
- garmin_fs_t *gmsd;
+ const char* shortname;
+ garmin_fs_t* gmsd;
shortname = (wpt->shortname) ? wpt->shortname : "";
gmsd = GMSD_FIND(wpt);
#ifdef UNICSV_GC_READY
if (! waypt_empty_gc_data(wpt)) {
- const geocache_data *gc_data = wpt->gc_data;
+ const geocache_data* gc_data = wpt->gc_data;
if (gc_data->id) {
gb_setbit(&unicsv_outp_flags, fld_gc_id);
}
static void
-unicsv_waypt_disp_cb(const waypoint *wpt)
+unicsv_waypt_disp_cb(const waypoint* wpt)
{
double lat, lon, alt;
- char *cout = NULL;
- const char *shortname;
- garmin_fs_t *gmsd;
+ char* cout = NULL;
+ const char* shortname;
+ garmin_fs_t* gmsd;
#ifdef UNICSV_GC_READY
- const geocache_data *gc_data = NULL;
+ const geocache_data* gc_data = NULL;
#endif
unicsv_waypt_ct++;
break;
case grid_lat_lon_dms: {
- char *sep, *tmp;
+ char* sep, *tmp;
cout = pretty_deg_format(lat, lon, 's', unicsv_fieldsep, 0);
sep = strchr(cout, ',');
*sep = '\0';
}
}
if FIELD_USED(fld_fix) {
- const char *fix;
+ const char* fix;
switch (wpt->fix) {
case fix_none:
fix = "none";
static void
-unicsv_wr_init(const char *filename)
+unicsv_wr_init(const char* filename)
{
fout = gbfopen(filename, "wb", MYNAME);
}
double
-fmt_distance(const double distance_meters, const char **tag)
+fmt_distance(const double distance_meters, const char** tag)
{
double d;
}
double
-fmt_altitude(const double distance_meters, const char **tag)
+fmt_altitude(const double distance_meters, const char** tag)
{
double d;
}
double
-fmt_speed(const double distance_meters_sec, const char **tag)
+fmt_speed(const double distance_meters_sec, const char** tag)
{
double d;
#ifdef DEBUG_MEM
#define DEBUG_FILENAME "/tmp/gpsbabel.debug"
-static FILE *debug_mem_file = NULL;
+static FILE* debug_mem_file = NULL;
void
debug_mem_open()
{
}
void
-debug_mem_output(char *format, ...)
+debug_mem_output(char* format, ...)
{
va_list args;
va_start(args, format);
}
#endif
-void *
+void*
#ifdef DEBUG_MEM
XMALLOC(size_t size, DEBUG_PARAMS)
#else
xmalloc(size_t size)
#endif
{
- void *obj = malloc(size);
+ void* obj = malloc(size);
#ifdef DEBUG_MEM
debug_mem_output("malloc, %x, %d, %s, %d\n",
return obj;
}
-void *
+void*
#ifdef DEBUG_MEM
XCALLOC(size_t nmemb, size_t size, DEBUG_PARAMS)
#else
xcalloc(size_t nmemb, size_t size)
#endif
{
- void *obj = calloc(nmemb, size);
+ void* obj = calloc(nmemb, size);
#ifdef DEBUG_MEM
debug_mem_output("calloc, %x, %d, %d, %s, %d\n",
obj, nmemb, size, file, line);
void
#ifdef DEBUG_MEM
-XFREE(const void *mem, DEBUG_PARAMS)
+XFREE(const void* mem, DEBUG_PARAMS)
#else
-xfree(const void *mem)
+xfree(const void* mem)
#endif
{
- free((void *) mem);
+ free((void*) mem);
#ifdef DEBUG_MEM
debug_mem_output("free, %x, %s, %d\n",
mem, file, line);
#endif
}
-char *
+char*
#ifdef DEBUG_MEM
-XSTRDUP(const char *s, DEBUG_PARAMS)
+XSTRDUP(const char* s, DEBUG_PARAMS)
#else
-xstrdup(const char *s)
+xstrdup(const char* s)
#endif
{
- char *o = s ? strdup(s) : strdup("");
+ char* o = s ? strdup(s) : strdup("");
#ifdef DEBUG_MEM
debug_mem_output("strdup, %x, %x, %s, %d\n",
o, s, file, line);
/*
* Duplicate at most sz bytes in str.
*/
-char *
+char*
#ifdef DEBUG_MEM
-XSTRNDUP(const char *str, size_t sz, DEBUG_PARAMS)
+XSTRNDUP(const char* str, size_t sz, DEBUG_PARAMS)
#else
-xstrndup(const char *str, size_t sz)
+xstrndup(const char* str, size_t sz)
#endif
{
size_t newlen = 0;
- char *cin = (char *)str;
- char *newstr;
+ char* cin = (char*)str;
+ char* newstr;
while ((newlen < sz) && (*cin != '\0')) {
newlen++;
cin++;
}
- newstr = (char *) xmalloc(newlen + 1);
+ newstr = (char*) xmalloc(newlen + 1);
memcpy(newstr, str, newlen);
newstr[newlen] = 0;
* Lazily trim whitespace (though not from allocated version)
* while copying.
*/
-char *
+char*
#ifdef DEBUG_MEM
-XSTRNDUPT(const char *str, size_t sz, DEBUG_PARAMS)
+XSTRNDUPT(const char* str, size_t sz, DEBUG_PARAMS)
#else
-xstrndupt(const char *str, size_t sz)
+xstrndupt(const char* str, size_t sz)
#endif
{
size_t newlen = 0;
- char *cin = (char *)str;
- char *newstr;
+ char* cin = (char*)str;
+ char* newstr;
while ((newlen < sz) && (*cin != '\0')) {
newlen++;
cin++;
}
- newstr = (char *) xmalloc(newlen + 1);
+ newstr = (char*) xmalloc(newlen + 1);
memcpy(newstr, str, newlen);
newstr[newlen] = 0;
rtrim(newstr);
return newstr;
}
-void *
+void*
#ifdef DEBUG_MEM
-XREALLOC(void *p, size_t s, DEBUG_PARAMS)
+XREALLOC(void* p, size_t s, DEBUG_PARAMS)
#else
-xrealloc(void *p, size_t s)
+xrealloc(void* p, size_t s)
#endif
{
- char *o = (char *) realloc(p,s);
+ char* o = (char*) realloc(p,s);
#ifdef DEBUG_MEM
if (p != NULL) {
debug_mem_output("realloc, %x, %x, %x, %s, %d\n", o, p, s, file, line);
/*
* For an allocated string, realloc it and append 's'
*/
-char *
+char*
#ifdef DEBUG_MEM
-XSTRAPPEND(char *src, const char *newd, DEBUG_PARAMS)
+XSTRAPPEND(char* src, const char* newd, DEBUG_PARAMS)
#else
-xstrappend(char *src, const char *newd)
+xstrappend(char* src, const char* newd)
#endif
{
size_t newsz;
}
newsz = strlen(src) + strlen(newd) + 1;
- src = (char *) xxrealloc(src, newsz, file, line);
+ src = (char*) xxrealloc(src, newsz, file, line);
strcat(src, newd);
return src;
/*
* Wrapper for open that honours - for stdin, stdout, unifies error text.
*/
-FILE *
-xfopen(const char *fname, const char *type, const char *errtxt)
+FILE*
+xfopen(const char* fname, const char* type, const char* errtxt)
{
- FILE *f;
+ FILE* f;
int am_writing = strchr(type, 'w') != NULL;
if (fname == NULL) {
*/
int
-xasprintf(char **strp, const char *fmt, ...)
+xasprintf(char** strp, const char* fmt, ...)
{
va_list args;
int res;
}
int
-xvasprintf(char **strp, const char *fmt, va_list ap)
+xvasprintf(char** strp, const char* fmt, va_list ap)
{
/* From http://perfec.to/vsnprintf/pasprintf.c */
/* size of first buffer malloc; start small to exercise grow routines */
#else
# define FIRSTSIZE 1
#endif
- char *buf = NULL;
+ char* buf = NULL;
int bufsize;
- char *newbuf;
+ char* newbuf;
size_t nextsize = 0;
int outsize;
va_list args;
bufsize = 0;
for (;;) {
if (bufsize == 0) {
- if ((buf = (char *) xmalloc(FIRSTSIZE)) == NULL) {
+ if ((buf = (char*) xmalloc(FIRSTSIZE)) == NULL) {
*strp = NULL;
return -1;
}
bufsize = FIRSTSIZE;
- } else if ((newbuf = (char *) xrealloc(buf, nextsize)) != NULL) {
+ } else if ((newbuf = (char*) xrealloc(buf, nextsize)) != NULL) {
buf = newbuf;
bufsize = nextsize;
} else {
if (bufsize > outsize + 1) {
const unsigned ptrsz = sizeof(buf);
if (((bufsize + ptrsz + 1) / ptrsz) > ((outsize + ptrsz + 1) / ptrsz)) {
- buf = (char *) xrealloc(buf, outsize + 1);
+ buf = (char*) xrealloc(buf, outsize + 1);
}
}
}
void
-rtrim(char *s)
+rtrim(char* s)
{
- char *t = s;
+ char* t = s;
if (!s || !*s) {
return;
/*
* Like trim, but trims whitespace from both beginning and end.
*/
-char *
-lrtrim(char *buff)
+char*
+lrtrim(char* buff)
{
- char *c;
+ char* c;
if (buff[0] == '\0') {
return buff;
}
if (c != buff) {
- char *src = c;
- char *dst = buff;
+ char* src = c;
+ char* dst = buff;
while (*src) {
*dst++ = *src++;
*/
int
-case_ignore_strcmp(const char *s1, const char *s2)
+case_ignore_strcmp(const char* s1, const char* s2)
{
for (; toupper(*s1) == toupper(*s2); ++ s1, ++s2) {
if (*s1 == 0) {
}
int
-case_ignore_strncmp(const char *s1, const char *s2, int n)
+case_ignore_strncmp(const char* s1, const char* s2, int n)
{
int rv = 0;
*/
int
-str_match(const char *str, const char *match)
+str_match(const char* str, const char* match)
{
- char *m, *s;
+ char* m, *s;
- s = (char *)str;
- m = (char *)match;
+ s = (char*)str;
+ m = (char*)match;
while (*m || *s) {
switch (*m) {
}
do {
- char *mx, *sx;
+ char* mx, *sx;
while (*s && (*s != *m)) {
s++;
*/
int
-case_ignore_str_match(const char *str, const char *match)
+case_ignore_str_match(const char* str, const char* match)
{
- char *s1, *s2;
+ char* s1, *s2;
int res;
s1 = strupper(xstrdup(str));
return res;
}
-char *
-strenquote(const char *str, const char quot_char)
+char*
+strenquote(const char* str, const char quot_char)
{
int len;
- const char *cin;
- char *cout;
- char *tmp;
+ const char* cin;
+ char* cout;
+ char* tmp;
if (str == NULL) {
cin = "";
} else {
- cin = (char *)str;
+ cin = (char*)str;
}
len = strlen(cin);
- cout = tmp = (char *) xmalloc((len * 2) + 3);
+ cout = tmp = (char*) xmalloc((len * 2) + 3);
*cout++ = quot_char;
while (*cin) {
}
void
-is_fatal(const int condition, const char *fmt, ...)
+is_fatal(const int condition, const char* fmt, ...)
{
va_list args;
char buff[128];
* Read 4 bytes in big-endian. Return as "int" in native endianness.
*/
signed int
-be_read32(const void *p)
+be_read32(const void* p)
{
- unsigned char *i = (unsigned char *) p;
+ unsigned char* i = (unsigned char*) p;
return i[0] << 24 | i[1] << 16 | i[2] << 8 | i[3];
}
signed int
-be_read16(const void *p)
+be_read16(const void* p)
{
- unsigned char *i = (unsigned char *) p;
+ unsigned char* i = (unsigned char*) p;
return i[0] << 8 | i[1];
}
unsigned int
-be_readu16(const void *p)
+be_readu16(const void* p)
{
- const unsigned char *i = (unsigned char *) p;
+ const unsigned char* i = (unsigned char*) p;
return i[0] << 8 | i[1];
}
void
-be_write16(void *addr, const unsigned value)
+be_write16(void* addr, const unsigned value)
{
- unsigned char *p = (unsigned char *) addr;
+ unsigned char* p = (unsigned char*) addr;
p[0] = value >> 8;
p[1] = value;
}
void
-be_write32(void *pp, const unsigned i)
+be_write32(void* pp, const unsigned i)
{
- char *p = (char *)pp;
+ char* p = (char*)pp;
p[0] = (i >> 24) & 0xff;
p[1] = (i >> 16) & 0xff;
}
signed int
-le_read16(const void *addr)
+le_read16(const void* addr)
{
- const unsigned char *p = (const unsigned char *) addr;
+ const unsigned char* p = (const unsigned char*) addr;
return p[0] | (p[1] << 8);
}
unsigned int
-le_readu16(const void *addr)
+le_readu16(const void* addr)
{
- const unsigned char *p = (const unsigned char *) addr;
+ const unsigned char* p = (const unsigned char*) addr;
return p[0] | (p[1] << 8);
}
signed int
-le_read32(const void *addr)
+le_read32(const void* addr)
{
- const unsigned char *p = (const unsigned char *) addr;
+ const unsigned char* p = (const unsigned char*) addr;
return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
}
unsigned int
-le_readu32(const void *addr)
+le_readu32(const void* addr)
{
- const unsigned char *p = (const unsigned char *) addr;
+ const unsigned char* p = (const unsigned char*) addr;
return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
}
* in host endianness.
*/
void
-le_read64(void *dest, const void *src)
+le_read64(void* dest, const void* src)
{
- char *cdest = (char *) dest;
- const char *csrc = (const char *) src;
+ char* cdest = (char*) dest;
+ const char* csrc = (const char*) src;
if (i_am_little_endian) {
memcpy(dest, src, 8);
}
void
-le_write16(void *addr, const unsigned value)
+le_write16(void* addr, const unsigned value)
{
- unsigned char *p = (unsigned char *) addr;
+ unsigned char* p = (unsigned char*) addr;
p[0] = value;
p[1] = value >> 8;
}
void
-le_write32(void *addr, const unsigned value)
+le_write32(void* addr, const unsigned value)
{
- unsigned char *p = (unsigned char *) addr;
+ unsigned char* p = (unsigned char*) addr;
p[0] = value;
p[1] = value >> 8;
p[2] = value >> 16;
*/
time_t
-mkgmtime(struct tm *t)
+mkgmtime(struct tm* t)
{
short month, year;
time_t result;
* which is evaluated by mktime
*/
time_t
-mklocaltime(struct tm *t)
+mklocaltime(struct tm* t)
{
time_t result;
struct tm check = *t;
* Return the (zero based) month number of the year or -1 for failure.
*/
signed int
-month_lookup(const char *m)
+month_lookup(const char* m)
{
- static const char *months[] = {
+ static const char* months[] = {
"JAN", "FEB", "MAR", "APR", "MAY", "JUN",
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC", NULL
};
- const char **mp;
+ const char** mp;
for (mp = months; *mp; mp++) {
if (0 == case_ignore_strcmp(*mp, m)) {
* that interesting to us anyway.
*/
#define EPOCH_TICKS 621355968000000000.0
-void dotnet_time_to_time_t(double dotnet, time_t *t, int *millisecs)
+void dotnet_time_to_time_t(double dotnet, time_t* t, int* millisecs)
{
// TODO: replace this with better interface with normal return values
// and called via a QDateTime.
* a GPX file from geocaching.com. Thus we sort of make all the other
* formats do lookups based on these strings.
*/
-const char *
-get_cache_icon(const waypoint *waypointp)
+const char*
+get_cache_icon(const waypoint* waypointp)
{
if (!global_opts.smart_icons) {
return NULL;
{
double ret;
char r[8];
- const void *p;
+ const void* p;
int i;
if (i_am_little_endian == read_le) {
// Word order is different on arm, but not on arm-eabi.
#if defined(__arm__) && !defined(__ARM_EABI__)
memcpy(&ret, p + 4, 4);
- memcpy(((void *)&ret) + 4, p, 4);
+ memcpy(((void*)&ret) + 4, p, 4);
#else
memcpy(&ret, p, 8);
#endif
{
float ret;
char r[4];
- const void *p;
+ const void* p;
int i;
if (i_am_little_endian == read_le) {
endian_write_double(void* ptr, double d, int write_le)
{
int i;
- char *optr = (char *) ptr;
+ char* optr = (char*) ptr;
// Word order is different on arm, but not on arm-eabi.
#if defined(__arm__) && !defined(__ARM_EABI__)
char r[8];
memcpy(r + 4, &d, 4);
- memcpy(r, ((void *)&d) + 4, 4);
+ memcpy(r, ((void*)&d) + 4, 4);
#else
- char *r = (char *)(void *)&d;
+ char* r = (char*)(void*)&d;
#endif
void
endian_write_float(void* ptr, float f, int write_le)
{
- char *r = (char *)(void *)&f;
+ char* r = (char*)(void*)&f;
int i;
- char *optr = (char *) ptr;
+ char* optr = (char*) ptr;
if (i_am_little_endian == write_le) {
memcpy(ptr, &f, 4);
}
float
-le_read_float(const void *ptr)
+le_read_float(const void* ptr)
{
return endian_read_float(ptr, 1);
}
void
-le_write_float(void *ptr, float f)
+le_write_float(void* ptr, float f)
{
endian_write_float(ptr,f,1);
}
float
-be_read_float(void *ptr)
+be_read_float(void* ptr)
{
return endian_read_float(ptr, 0);
}
void
-be_write_float(void *ptr, float f)
+be_write_float(void* ptr, float f)
{
endian_write_float(ptr,f,0);
}
double
-le_read_double(const void *ptr)
+le_read_double(const void* ptr)
{
return endian_read_double(ptr,1);
}
void
-le_write_double(void *ptr, double d)
+le_write_double(void* ptr, double d)
{
endian_write_double(ptr,d,1);
}
double
-be_read_double(void *ptr)
+be_read_double(void* ptr)
{
return endian_read_double(ptr,0);
}
void
-be_write_double(void *ptr, double d)
+be_write_double(void* ptr, double d)
{
endian_write_double(ptr,d,0);
}
* Returns an allocated copy if substitution was made, otherwise returns NULL.
* Doesn't try to make an optimally sized dest buffer.
*/
-char *
-strsub(const char *s, const char *search, const char *replace)
+char*
+strsub(const char* s, const char* search, const char* replace)
{
- const char *p;
+ const char* p;
int len = strlen(s);
int slen = strlen(search);
int rlen = strlen(replace);
- char *d;
+ char* d;
p = strstr(s, search);
if (!slen || !p) {
return NULL;
}
- d = (char *) xmalloc(len + rlen);
+ d = (char*) xmalloc(len + rlen);
/* Copy first part */
len = p - s;
/*
* As strsub, but do it globally.
*/
-char *
-gstrsub(const char *s, const char *search, const char *replace)
+char*
+gstrsub(const char* s, const char* search, const char* replace)
{
int ooffs = 0;
- char *o, *c;
- char *src = (char *)s;
+ char* o, *c;
+ char* src = (char*)s;
int olen = strlen(src);
int slen = strlen(search);
int rlen = strlen(replace);
- o = (char *) xmalloc(olen + 1);
+ o = (char*) xmalloc(olen + 1);
while ((c = strstr(src, search))) {
olen += (rlen - slen);
- o = (char *) xrealloc(o, olen + 1);
+ o = (char*) xrealloc(o, olen + 1);
memcpy(o + ooffs, src, c - src);
ooffs += (c - src);
src = c + slen;
/*
* Like strstr, but starts from back of string.
*/
-const char *
-xstrrstr(const char *s1, const char *s2)
+const char*
+xstrrstr(const char* s1, const char* s2)
{
- const char *r = NULL, *next = NULL;
+ const char* r = NULL, *next = NULL;
while (next = strstr(s1, s2), NULL != next) {
r = next;
/*
*
*/
-char *
-strupper(char *src)
+char*
+strupper(char* src)
{
- char *c;
+ char* c;
for (c = src; *c; c++) {
*c = toupper(*c);
/*
*
*/
-char *
-strlower(char *src)
+char*
+strlower(char* src)
{
- char *c;
+ char* c;
for (c = src; *c; c++) {
*c = tolower(*c);
return src;
}
-char *
+char*
rot13(const QString& s)
{
- char *result = xstrdup(s.toUtf8().data());
- char *cur = result;
+ char* result = xstrdup(s.toUtf8().data());
+ char* cur = result;
int flip = 1;
while (cur && *cur) {
if (flip) {
* a format usable for strftime and others
*/
-char *
-convert_human_date_format(const char *human_datef)
+char*
+convert_human_date_format(const char* human_datef)
{
- char *result, *cin, *cout;
+ char* result, *cin, *cout;
char prev;
int ylen;
- result = (char *) xcalloc((2*strlen(human_datef)) + 1, 1);
+ result = (char*) xcalloc((2*strlen(human_datef)) + 1, 1);
cout = result;
prev = '\0';
ylen = 0;
- for (cin = (char *)human_datef; *cin; cin++) {
+ for (cin = (char*)human_datef; *cin; cin++) {
char okay = 1;
if (toupper(*cin) != 'Y') {
* a format usable for strftime and others
*/
-char *
-convert_human_time_format(const char *human_timef)
+char*
+convert_human_time_format(const char* human_timef)
{
- char *result, *cin, *cout;
+ char* result, *cin, *cout;
char prev;
- result = (char *) xcalloc((2*strlen(human_timef)) + 1, 1);
+ result = (char*) xcalloc((2*strlen(human_timef)) + 1, 1);
cout = result;
prev = '\0';
- for (cin = (char *)human_timef; *cin; cin++) {
+ for (cin = (char*)human_timef; *cin; cin++) {
int okay = 1;
if (isalpha(*cin)) {
* sep = string between lat and lon (separator)
* html = 1 for html output otherwise text
*/
-char *
-pretty_deg_format(double lat, double lon, char fmt, const char *sep, int html)
+char*
+pretty_deg_format(double lat, double lon, char fmt, const char* sep, int html)
{
double latmin, lonmin, latsec, lonsec;
int latint, lonint;
char latsig, lonsig;
- char *result;
+ char* result;
latsig = lat < 0 ? 'S':'N';
lonsig = lon < 0 ? 'W':'E';
latint = abs((int) lat);
* </body> and </html>- stop processing altogether
* <style> </style> - stop overriding styles for everything
*/
-char *
+char*
strip_nastyhtml(const QString& in)
{
- char *returnstr, *sp;
- char *lcstr, *lcp;
+ char* returnstr, *sp;
+ char* lcstr, *lcp;
sp = returnstr = xstrdup(in.toUtf8().data());
lcp = lcstr = strlower(xstrdup(in.toUtf8().data()));
* pleasant for a human reader. Yes, this falls down in all kinds of
* ways such as spaces within the tags, etc.
*/
-char *
-strip_html(const utf_string *in)
+char*
+strip_html(const utf_string* in)
{
char* outstring, *out;
char* incopy, *instr;
/*
* We only shorten, so just dupe the input buf for space.
*/
- outstring = out = xstrdup(CSTR(in->utfstring));
+ outstring = out = xstrdup(CSTR(in->utfstring));
tag[0] = 0;
while (*instr) {
}
typedef struct {
- const char * text;
- const char * entity;
+ const char* text;
+ const char* entity;
int not_html;
} entity_types;
};
static
-char *
-entitize(const char * str, int is_html)
+char*
+entitize(const char* str, int is_html)
{
int elen, ecount, nsecount;
- entity_types *ep;
- const char * cp;
- char * p, * tmp, * xstr;
+ entity_types* ep;
+ const char* cp;
+ char* p, * tmp, * xstr;
int bytes = 0;
int value = 0;
#endif
/* enough space for the whole string plus entity replacements, if any */
- tmp = (char *) xcalloc((strlen(str) + elen + 1), 1);
+ tmp = (char*) xcalloc((strlen(str) + elen + 1), 1);
strcpy(tmp, str);
/* no entity replacements */
* Public callers for the above to hide the absence of &apos from HTML
*/
-char * xml_entitize(const char * str)
+char* xml_entitize(const char* str)
{
return entitize(str, 0);
}
-char * html_entitize(const char * str)
+char* html_entitize(const char* str)
{
return entitize(str, 1);
}
* xml_tag utilities
*/
-xml_tag *xml_next(xml_tag *root, xml_tag *cur)
+xml_tag* xml_next(xml_tag* root, xml_tag* cur)
{
if (cur->child) {
cur = cur->child;
return cur;
}
-xml_tag *xml_findnext(xml_tag *root, xml_tag *cur, const char *tagname)
+xml_tag* xml_findnext(xml_tag* root, xml_tag* cur, const char* tagname)
{
- xml_tag *result = cur;
+ xml_tag* result = cur;
do {
result = xml_next(root, result);
} while (result && case_ignore_strcmp(result->tagname, tagname));
return result;
}
-xml_tag *xml_findfirst(xml_tag *root, const char *tagname)
+xml_tag* xml_findfirst(xml_tag* root, const char* tagname)
{
return xml_findnext(root, root, tagname);
}
-char *xml_attribute(xml_tag *tag, const char *attrname)
+char* xml_attribute(xml_tag* tag, const char* attrname)
{
- char *result = NULL;
+ char* result = NULL;
if (tag->attributes) {
- char **attr = tag->attributes;
+ char** attr = tag->attributes;
while (attr && *attr) {
if (0 == case_ignore_strcmp(*attr, attrname)) {
result = attr[1];
return result;
}
-const char *get_filename(const char *fname)
+const char* get_filename(const char* fname)
{
- const char *res;
- const char *cb;
- const char *cs;
+ const char* res;
+ const char* cb;
+ const char* cs;
cb = strrchr(fname, '\\');
cs = strrchr(fname, '/');
res = (cs > cb) ? cs : cb;
}
- return (res == NULL) ? (char *) fname : ++res;
+ return (res == NULL) ? (char*) fname : ++res;
}
/* bit manipulation functions */
/*
* setbit: Set bit number [nr] of buffer [buf]
*/
-void gb_setbit(void *buf, const uint32_t nr)
+void gb_setbit(void* buf, const uint32_t nr)
{
- unsigned char *bytes = (unsigned char *) buf;
+ unsigned char* bytes = (unsigned char*) buf;
bytes[nr / 8] |= (1 << (nr % 8));
}
/*
* setbit: Get state of bit number [nr] of buffer [buf]
*/
-char gb_getbit(const void *buf, const uint32_t nr)
+char gb_getbit(const void* buf, const uint32_t nr)
{
- const unsigned char *bytes = (const unsigned char *) buf;
+ const unsigned char* bytes = (const unsigned char*) buf;
return (bytes[nr / 8] & (1 << (nr % 8)));
}
/*
* gb_int2ptr: Needed, when sizeof(*void) != sizeof(int) ! compiler warning !
*/
-void *gb_int2ptr(const int i)
+void* gb_int2ptr(const int i)
{
union {
- void *p;
+ void* p;
int i;
} x = { NULL };
/*
* gb_ptr2int: Needed, when sizeof(*void) != sizeof(int) ! compiler warning !
*/
-int gb_ptr2int(const void *p)
+int gb_ptr2int(const void* p)
{
union {
- const void *p;
+ const void* p;
int i;
} x = { p };
};
unsigned long
-get_crc32(const void * data, int datalen)
+get_crc32(const void* data, int datalen)
{
unsigned long crc = 0xFFFFFFFF;
- const unsigned char * cp = (unsigned char *)data;
+ const unsigned char* cp = (unsigned char*)data;
- while (cp < ((unsigned char *)data + datalen)) {
+ while (cp < ((unsigned char*)data + datalen)) {
crc = ((crc >> 8) & 0x00FFFFFF) ^ crc32_table[(crc ^ *cp) &0xFF];
cp++;
}
* As above, but on null-terminated string.
*/
unsigned long
-get_crc32_s(const void *data)
+get_crc32_s(const void* data)
{
unsigned long crc = 0xFFFFFFFF;
- const unsigned char* cp = (unsigned char *)data;
+ const unsigned char* cp = (unsigned char*)data;
for (; *cp; cp++) {
crc = ((crc >> 8) & 0x00FFFFFF) ^ crc32_table[(crc ^ *cp) &0xFF];
void
gb_uuid_generate(uuid_t uu)
{
- unsigned char *cp;
+ unsigned char* cp;
int i;
for (cp = uu, i = 0; i < 16; i++) {
if (getenv("GPSBABEL_FREEZE_TIME")) {
/* copied from dg-100.cpp */
static void
-v900_log(const char *fmt, ...)
+v900_log(const char* fmt, ...)
{
va_list ap;
}
static void
-v900_rd_init(const char *fname)
+v900_rd_init(const char* fname)
{
v900_log("%s(%s)\n",__func__,fname);
/* note: file is opened in binary mode, since lines end with \r\n, and in windows text mode
} line;
int is_advanced_mode = 0;
int lc = 0;
- route_head *track;
+ route_head* track;
v900_log("%s\n",__func__);
track_add_head(track);
while (1) {
- waypoint *wpt;
+ waypoint* wpt;
char c;
int bad = 0;
int record_len = is_advanced_mode ? sizeof(line.adv) : sizeof(line.bas);
track_add_wpt(track, wpt);
if (line.bas.common.tag != 'T') {
- waypoint *wpt2;
+ waypoint* wpt2;
// A 'G' tag appears to be a 'T' tag, but generated on the trailing
// edge of a DGPS fix as it decays to an SPS fix. See 1/13/13 email
// thread on gpsbabel-misc with Jamie Robertson.
wpt2 = waypt_dupe(wpt);
if (line.bas.common.tag == 'V') { // waypoint with voice recording?
char vox_file_name[sizeof(line.adv.vox)+5];
- const char *vox = is_advanced_mode ? line.adv.vox : line.bas.vox;
+ const char* vox = is_advanced_mode ? line.adv.vox : line.bas.vox;
assert(vox[0] != '\0');
strcpy(vox_file_name,vox);
strcat(vox_file_name,".WAV");
#include "defs.h"
#include "jeeps/gpsmath.h"
-static gbfile *file_out;
+static gbfile* file_out;
static short_handle mkshort_handle;
-static char *vcf_encrypt = NULL;
+static char* vcf_encrypt = NULL;
#define MYNAME "VCF"
};
static void
-wr_init(const char *fname)
+wr_init(const char* fname)
{
file_out = gbfopen(fname, "w", MYNAME);
mkshort_handle = mkshort_new_handle();
* newlines as we go.
*/
static void
-vcf_print_utf(const utf_string *s)
+vcf_print_utf(const utf_string* s)
{
- char *p, *p2, *p3;
- char *stripped_html;
+ char* p, *p2, *p3;
+ char* stripped_html;
if (!s) {
return;
}
static void
-vcf_print(const char *s)
+vcf_print(const char* s)
{
- char *p;
+ char* p;
if (!s) {
return;
}
static void
-vcf_disp(const waypoint *wpt)
+vcf_disp(const waypoint* wpt)
{
int latint, lonint;
vcf_print_utf(&wpt->gc_data->desc_long);
gbfprintf(file_out, "\\n\\nHINT:\\n");
if (vcf_encrypt) {
- char *s = rot13(wpt->gc_data->hint);
+ char* s = rot13(wpt->gc_data->hint);
vcf_print(s);
xfree(s);
} else {
#define MYNAME "vecs.c"
typedef struct {
- ff_vecs_t *vec;
- const char *name;
- const char *desc;
- const char *extension;
- const char *parent;
+ ff_vecs_t* vec;
+ const char* name;
+ const char* desc;
+ const char* extension;
+ const char* parent;
} vecs_t;
extern ff_vecs_t an1_vecs;
void
init_vecs(void)
{
- vecs_t *vec = vec_list;
+ vecs_t* vec = vec_list;
while (vec->vec) {
- arglist_t *ap;
+ arglist_t* ap;
if (vec->vec->args) {
for (ap = vec->vec->args; ap->argstring; ap++) {
ap->argvalptr = NULL;
}
int
-is_integer(const char *c)
+is_integer(const char* c)
{
return isdigit(c[0]) || ((c[0] == '+' || c[0] == '-') && isdigit(c[1]));
}
void
exit_vecs(void)
{
- vecs_t *vec = vec_list;
+ vecs_t* vec = vec_list;
while (vec->vec) {
- arglist_t *ap;
+ arglist_t* ap;
if (vec->vec->exit) {
(*vec->vec->exit)();
}
}
void
-assign_option(const char *module, arglist_t *ap, const char *val)
+assign_option(const char* module, arglist_t* ap, const char* val)
{
- const char *c;
+ const char* c;
if (ap->argval == NULL) {
fatal("%s: No local variable defined for option \"%s\"!", module, ap->argstring);
if (case_ignore_strcmp(val, ap->argstring) == 0) {
c = "";
} else {
- c = (char *)val;
+ c = (char*)val;
}
switch (ap->argtype & ARGTYPE_TYPEMASK) {
}
void
-disp_vec_options(const char *vecname, arglist_t *ap)
+disp_vec_options(const char* vecname, arglist_t* ap)
{
for (; ap && ap->argstring; ap++) {
if (*ap->argval && ap->argval) {
}
}
-ff_vecs_t *
-find_vec(const char *vecname, const char **opts)
+ff_vecs_t*
+find_vec(const char* vecname, const char** opts)
{
- vecs_t *vec = vec_list;
- style_vecs_t *svec = style_list;
- char *v = xstrdup(vecname);
- char *svecname = strtok(v, ",");
+ vecs_t* vec = vec_list;
+ style_vecs_t* svec = style_list;
+ char* v = xstrdup(vecname);
+ char* svecname = strtok(v, ",");
int found = 0;
if (vecname == NULL) {
if (vec->vec->args) {
for (arglist_t* ap = vec->vec->args; ap->argstring; ap++) {
- const char *opt;
+ const char* opt;
if (res) {
opt = get_option(*opts, ap->argstring);
if (opt) {
found = 1;
assign_option(svecname, ap, opt);
- xfree((char *)opt);
+ xfree((char*)opt);
continue;
}
}
if (vec_list[0].vec->args) {
for (arglist_t* ap = vec_list[0].vec->args; ap->argstring; ap++) {
- const char *opt;
+ const char* opt;
if (res) {
opt = get_option(*opts, ap->argstring);
if (opt) {
found = 1;
assign_option(svecname, ap, opt);
- xfree((char *)opt);
+ xfree((char*)opt);
continue;
}
}
* Find and return a specific argument in an arg list.
* Modelled approximately after getenv.
*/
-char *
+char*
#ifdef DEBUG_MEM
-GET_OPTION(const char *iarglist, const char *argname, DEBUG_PARAMS)
+GET_OPTION(const char* iarglist, const char* argname, DEBUG_PARAMS)
#else
-get_option(const char *iarglist, const char *argname)
+get_option(const char* iarglist, const char* argname)
#endif
{
size_t arglen = strlen(argname);
- char *arglist;
- char *rval = NULL;
- char *arg;
- char *argp;
+ char* arglist;
+ char* rval = NULL;
+ char* arg;
+ char* argp;
if (!iarglist) {
return NULL;
* parse for help on available command line options.
*/
static signed int
-alpha(const void *a, const void *b)
+alpha(const void* a, const void* b)
{
- const vecs_t *const *ap = (const vecs_t *const*) a;
- const vecs_t *const *bp = (const vecs_t *const*) b;
+ const vecs_t* const* ap = (const vecs_t *const*) a;
+ const vecs_t* const* bp = (const vecs_t *const*) b;
return case_ignore_strcmp((*ap)->desc , (*bp)->desc);
}
* alphabetically. Returns an allocated copy of a style_vecs_array
* that's populated and sorted.
*/
-vecs_t **
-sort_and_unify_vecs(int *ctp)
+vecs_t**
+sort_and_unify_vecs(int* ctp)
{
int vc;
- vecs_t **svp;
- vecs_t *vec;
+ vecs_t** svp;
+ vecs_t* vec;
#if CSVFMTS_ENABLED
- style_vecs_t *svec;
+ style_vecs_t* svec;
#endif
int i = 0;
#endif // CSVFMTS_ENABLED
- svp = (vecs_t **)xcalloc(vc, sizeof(style_vecs_t *));
+ svp = (vecs_t**)xcalloc(vc, sizeof(style_vecs_t*));
/* Normal vecs are easy; populate the first part of the array. */
for (vec = vec_list; vec->vec; vec++, i++) {
svp[i] = vec;
/* Walk the style list, parse the entries, dummy up a "normal" vec */
for (svec = style_list; svec->name; svec++, i++) {
xcsv_read_internal_style(svec->style_buf);
- svp[i] = (vecs_t*) xcalloc(1, sizeof **svp);
+ svp[i] = (vecs_t*) xcalloc(1, sizeof** svp);
svp[i]->name = svec->name;
svp[i]->vec = (ff_vecs_t*) xmalloc(sizeof(*svp[i]->vec));
svp[i]->extension = xcsv_file.extension;
void
disp_vecs(void)
{
- vecs_t **svp;
- arglist_t *ap;
+ vecs_t** svp;
+ arglist_t* ap;
int vc;
int i = 0;
}
void
-disp_vec(const char *vecname)
+disp_vec(const char* vecname)
{
- vecs_t **svp;
- arglist_t *ap;
+ vecs_t** svp;
+ arglist_t* ap;
int vc;
int i = 0;
static void
disp_v1(ff_type t)
{
- const char *tstring;
+ const char* tstring;
switch (t) {
case ff_type_file:
}
static void
-disp_v2(ff_vecs_t *v)
+disp_v2(ff_vecs_t* v)
{
int i;
for (i = 0; i < 3; i++) {
putchar('\t');
}
-const char *
+const char*
name_option(long type)
{
- const char *at[] = {
+ const char* at[] = {
"unknown",
"integer",
"float",
}
static
-void disp_help_url(const vecs_t *vec, arglist_t *arg)
+void disp_help_url(const vecs_t* vec, arglist_t* arg)
{
printf("\t" WEB_DOC_DIR "/fmt_%s.html", vec->name);
if (arg) {
static void
-disp_v3(const vecs_t *vec)
+disp_v3(const vecs_t* vec)
{
- arglist_t *ap;
+ arglist_t* ap;
disp_help_url(vec, NULL);
for (ap = vec->vec->args; ap && ap->argstring; ap++) {
void
disp_formats(int version)
{
- vecs_t **svp;
- vecs_t *vec;
+ vecs_t** svp;
+ vecs_t* vec;
int i, vc = 0;
switch (version) {
#define VIDAONE_VER "ver"
-static char *vidaone_opt_ver;
+static char* vidaone_opt_ver;
static int vidaone_ver;
static
ARG_TERMINATOR
};
-static gbfile *fin, *fout;
+static gbfile* fin, *fout;
/*******************************************************************************
* %%% global callbacks called by gpsbabel main process %%% *
*******************************************************************************/
static void
-vidaone_rd_init(const char *fname)
+vidaone_rd_init(const char* fname)
{
vidaone_ver = atoi(vidaone_opt_ver);
fin = gbfopen(fname, "rb", MYNAME);
static void
vidaone_read(void)
{
- route_head *trk = NULL;
+ route_head* trk = NULL;
while (! gbfeof(fin)) {
- waypoint *wpt = waypt_new();
+ waypoint* wpt = waypt_new();
wpt->latitude = gbfgetdbl(fin);
wpt->longitude = gbfgetdbl(fin);
}
static void
-vidaone_wr_init(const char *fname)
+vidaone_wr_init(const char* fname)
{
vidaone_ver = atoi(vidaone_opt_ver);
fout = gbfopen(fname, "wb", MYNAME);
}
static void
-vidaone_trkpt(const waypoint *wpt)
+vidaone_trkpt(const waypoint* wpt)
{
gbfputdbl(wpt->latitude, fout);
gbfputdbl(wpt->longitude, fout);
#include "defs.h"
#include "grtcirc.h"
-static gbfile *infile =NULL;
-static gbfile *ofs =NULL;
+static gbfile* infile =NULL;
+static gbfile* ofs =NULL;
static long count =0;
const long vitosmt_version =2;
const size_t vitosmt_headersize =24;
const size_t vitosmt_datasize =64;
-static unsigned char *
-ReadRecord(gbfile *f, gbsize_t size)
+static unsigned char*
+ReadRecord(gbfile* f, gbsize_t size)
{
- unsigned char *result = (unsigned char *) xmalloc(size);
+ unsigned char* result = (unsigned char*) xmalloc(size);
gbfread(result, size, 1, f);
return result;
static void
-rd_init(const char *fname)
+rd_init(const char* fname)
{
infile = gbfopen_le(fname, "rb", MYNAME);
}
long check1 =-1;
long check2 =-2;
long check3 =-3;
- route_head *route_head =0;
- waypoint *wpt_tmp =0;
+ route_head* route_head =0;
+ waypoint* wpt_tmp =0;
double latrad =0;
double lonrad =0;
double elev =0;
}
static void
-wr_init(const char *fname)
+wr_init(const char* fname)
{
warning(MYNAME " write: format is experimental and may crash Vito Navigator II.\n");
ofs = gbfopen_le(fname, "wb", MYNAME);
}
static void
-vitosmt_waypt_pr(const waypoint *waypointp)
+vitosmt_waypt_pr(const waypoint* waypointp)
{
- unsigned char * workbuffer =0;
+ unsigned char* workbuffer =0;
size_t position =0;
double seconds =0;
++count;
- workbuffer = (unsigned char *) xcalloc(vitosmt_datasize,1);
+ workbuffer = (unsigned char*) xcalloc(vitosmt_datasize,1);
WriteDouble(&workbuffer[position], RAD(waypointp->latitude));
position += sizeof(double);
vitosmt_write(void)
{
time_t now = 0;
- unsigned char * workbuffer =0;
+ unsigned char* workbuffer =0;
size_t position =0;
workbuffer = (unsigned char*) xcalloc(vitosmt_headersize,1);
#define TM_YEAR_ZERO 1900
#define TM_MONTH_ZERO 1
-static gbfile *infile = 0;
+static gbfile* infile = 0;
static int count = 0;
static const int vitovtt_version = 3;
static const int vitovtt_microsecondscale = 30;
static void
-rd_init(const char *fname)
+rd_init(const char* fname)
{
infile = gbfopen_le(fname, "rb", MYNAME);
}
vitovtt_read(void)
{
int version = 0;
- route_head *route_head = 0;
- waypoint *wpt_tmp = 0;
+ route_head* route_head = 0;
+ waypoint* wpt_tmp = 0;
int scaled_lat = 0;
int scaled_lon = 0;
double altitude = 0;
* By default, zero the allocated thingy.
*/
if (flags & VMFL_NOZERO) {
- vm.mem = (char *) xmalloc(size);
+ vm.mem = (char*) xmalloc(size);
} else {
- vm.mem = (char *) xcalloc(size, 1);
+ vm.mem = (char*) xcalloc(size, 1);
}
vm.size = size;
return vm;
}
void
-vmem_free(vmem_t *vm)
+vmem_free(vmem_t* vm)
{
if (vm->mem) {
xfree(vm->mem);
* will only grow for a while then reach a steady state.
*/
void
-vmem_realloc(vmem_t *vm, size_t size)
+vmem_realloc(vmem_t* vm, size_t size)
{
/*
* Reallocate only if we must.
*/
if (size > vm->size) {
- vm->mem = (char *) xrealloc(vm->mem, size);
+ vm->mem = (char*) xrealloc(vm->mem, size);
vm->size = size;
}
return;
ARG_TERMINATOR
};
-static gbfile *vpl_file_in;
-static route_head *track_head;
+static gbfile* vpl_file_in;
+static route_head* track_head;
/*******************************************************************************
* %%% global callbacks called by gpsbabel main process %%% *
*******************************************************************************/
static void
-vpl_rd_init(const char *fname)
+vpl_rd_init(const char* fname)
{
vpl_file_in = gbfopen(fname, "r", MYNAME);
}
static void
vpl_read(void)
{
- char *ibuf;
+ char* ibuf;
// Set up a track
if (track_head == NULL) {
}
static void
-vpl_wr_init(const char *fname)
+vpl_wr_init(const char* fname)
{
fatal("Writing file of type %s is not support\n", MYNAME);
}
*******************************************************************************/
void
-vpl_parse_75_sentence(const char *ibuf)
+vpl_parse_75_sentence(const char* ibuf)
{
uint32_t ymd, hms;
int32_t lat_raw, lon_raw;
int16_t alt, speed_raw;
uint16_t hdg_raw;
uint8_t sats, hdop_raw, vdop_raw;
- waypoint *waypt;
+ waypoint* waypt;
struct tm tm;
// The files have DOS line endings (CR/LF) but we don't care, because we
#if NEWQ
QList<waypoint*> waypt_list;
-queue waypt_head; // This is here solely to freak out the formats that are
- // looking into what should be a private members.
+queue waypt_head; // This is here solely to freak out the formats that are
+// looking into what should be a private members.
#else
queue waypt_head;
#endif
// This whole thing is a poor-man's copy constructor. It exists mostly
// as a bridge from our non-reference counted C types to classes now.
-waypoint *
-waypt_dupe(const waypoint *wpt)
+waypoint*
+waypt_dupe(const waypoint* wpt)
{
/*
* This and waypt_free should be closely synced.
}
void
-waypt_add(waypoint *wpt)
+waypt_add(waypoint* wpt)
{
double lat_orig = wpt->latitude;
double lon_orig = wpt->longitude;
}
void
-waypt_del(waypoint *wpt)
+waypt_del(waypoint* wpt)
{
dequeue(&wpt->Q);
waypt_ct--;
/*
* A constructor for a single waypoint.
*/
-waypoint *
+waypoint*
waypt_new(void)
{
- waypoint *wpt = new waypoint;
+ waypoint* wpt = new waypoint;
#ifdef DEBUG_MEM
wpt->altitude = unknown_alt; // should this be "latitude" instead of "altitude"?
wpt->longitude = unknown_alt;
}
void
-waypt_disp(const waypoint *wpt)
+waypt_disp(const waypoint* wpt)
{
if (wpt->GetCreationTime().isValid()) {
printf("%s ", qPrintable(wpt->creation_time.toString()));
printposn(wpt->longitude,0);
if (wpt->description) {
- char *tmpdesc = xstrdup(wpt->description);
+ char* tmpdesc = xstrdup(wpt->description);
printf("%s/%s",
global_opts.synthesize_shortnames ?
mkshort(mkshort_handle, tmpdesc) :
}
void
-waypt_disp_session(const session_t *se, waypt_cb cb)
+waypt_disp_session(const session_t* se, waypt_cb cb)
{
int i = 0;
#if NEWQ
foreach(waypoint* waypointp, waypt_list) {
#else
- queue *elem, *tmp;
- waypoint *waypointp;
+ queue* elem, *tmp;
+ waypoint* waypointp;
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- waypointp = (waypoint *) elem;
+ waypointp = (waypoint*) elem;
#endif
if ((se == NULL) || (waypointp->session == se)) {
if (global_opts.verbose_status) {
}
void
-waypt_init_bounds(bounds *bounds)
+waypt_init_bounds(bounds* bounds)
{
/* Set data out of bounds so that even one waypoint will reset */
bounds->max_lat = -9999;
}
int
-waypt_bounds_valid(bounds *bounds)
+waypt_bounds_valid(bounds* bounds)
{
/* Returns true if bb has any 'real' data in it */
return bounds->max_lat > -9999;
* Recompund bounding box based on new position point.
*/
void
-waypt_add_to_bounds(bounds *bounds, const waypoint *waypointp)
+waypt_add_to_bounds(bounds* bounds, const waypoint* waypointp)
{
if (waypointp->latitude > bounds->max_lat) {
bounds->max_lat = waypointp->latitude;
*/
void
-waypt_compute_bounds(bounds *bounds)
+waypt_compute_bounds(bounds* bounds)
{
waypt_init_bounds(bounds);
#if NEWQ
foreach(waypoint* waypointp, waypt_list) {
#else
- queue *elem, *tmp;
- waypoint *waypointp;
+ queue* elem, *tmp;
+ waypoint* waypointp;
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- waypointp = (waypoint *) elem;
+ waypointp = (waypoint*) elem;
#endif
waypt_add_to_bounds(bounds, waypointp);
}
}
-waypoint *
-find_waypt_by_name(const char *name)
+waypoint*
+find_waypt_by_name(const char* name)
{
#if NEWQ
foreach(waypoint* waypointp, waypt_list) {
#else
- queue *elem, *tmp;
- waypoint *waypointp;
+ queue* elem, *tmp;
+ waypoint* waypointp;
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
- waypointp = (waypoint *) elem;
+ waypointp = (waypoint*) elem;
#endif
if (0 == strcmp(waypointp->shortname, name)) {
return waypointp;
}
void
-waypt_free(waypoint *wpt)
+waypt_free(waypoint* wpt)
{
/*
* This and waypt_dupe should be closely synced.
#if 0
// these are now ref counted...
if (wpt->url_next) {
- url_link *url_next;
+ url_link* url_next;
for (url_next = wpt->url_next; url_next;) {
- url_link *tonuke = url_next;
+ url_link* tonuke = url_next;
url_next = tonuke->url_next;
xfree(tonuke);
}
#endif
if (wpt->gc_data != &empty_gc_data) {
- geocache_data *gc_data = (geocache_data *)wpt->gc_data;
+ geocache_data* gc_data = (geocache_data*)wpt->gc_data;
delete gc_data;
}
#if NEWQ
void
-waypt_flush(queue* head) {
+waypt_flush(queue* head)
+{
while (!waypt_list.isEmpty()) {
waypt_free(waypt_list.takeFirst());
}
}
#else
void
-waypt_flush(queue *head)
+waypt_flush(queue* head)
{
- queue *elem, *tmp;
+ queue* elem, *tmp;
QUEUE_FOR_EACH(head, elem, tmp) {
- waypoint *q = (waypoint *) dequeue(elem);
+ waypoint* q = (waypoint*) dequeue(elem);
waypt_free(q);
if (head == &waypt_head) {
waypt_ct--;
}
void
-waypt_backup(signed int *count, queue **head_bak)
+waypt_backup(signed int* count, queue** head_bak)
{
- queue *elem, *tmp, *qbackup;
- waypoint *wpt;
+ queue* elem, *tmp, *qbackup;
+ waypoint* wpt;
int no = 0;
- qbackup = (queue *) xcalloc(1, sizeof(*qbackup));
+ qbackup = (queue*) xcalloc(1, sizeof(*qbackup));
QUEUE_INIT(qbackup);
#if NEWQ
// Why does this code exist?
waypt_ct = 0;
QUEUE_FOR_EACH(qbackup, elem, tmp) {
- wpt = (waypoint *)elem;
+ wpt = (waypoint*)elem;
waypt_add(waypt_dupe(wpt));
no++;
}
}
void
-waypt_restore(signed int count, queue *head_bak)
+waypt_restore(signed int count, queue* head_bak)
{
if (head_bak == NULL) {
return;
}
void
-waypt_add_url(waypoint *wpt, const QString& link, const QString& url_link_text)
+waypt_add_url(waypoint* wpt, const QString& link, const QString& url_link_text)
{
wpt->url_link_list_.push_back(UrlLink(link, url_link_text));
}
*/
double
-waypt_time(const waypoint *wpt)
+waypt_time(const waypoint* wpt)
{
if (!wpt->creation_time.isValid()) {
return (double) 0;
*/
double
-waypt_distance_ex(const waypoint *A, const waypoint *B)
+waypt_distance_ex(const waypoint* A, const waypoint* B)
{
double res = 0;
garmin_fs_p gmsd;
}
if ((gmsd = GMSD_FIND(A)) && (gmsd->ilinks != NULL)) {
- garmin_ilink_t *link = gmsd->ilinks;
+ garmin_ilink_t* link = gmsd->ilinks;
res = gcgeodist(A->latitude, A->longitude, link->lat, link->lon);
while (link->next != NULL) {
- garmin_ilink_t *prev = link;
+ garmin_ilink_t* prev = link;
link = link->next;
res += gcgeodist(prev->lat, prev->lon, link->lat, link->lon);
}
}
double
-waypt_distance(const waypoint *A, const waypoint *B)
+waypt_distance(const waypoint* A, const waypoint* B)
{
if ((A == NULL) || (B == NULL)) {
return 0;
*/
double
-waypt_speed_ex(const waypoint *A, const waypoint *B)
+waypt_speed_ex(const waypoint* A, const waypoint* B)
{
double dist, time;
*/
double
-waypt_speed(const waypoint *A, const waypoint *B)
+waypt_speed(const waypoint* A, const waypoint* B)
{
double dist, time;
* Calculates "Course True" from A to B
*/
double
-waypt_course(const waypoint *A, const waypoint *B)
+waypt_course(const waypoint* A, const waypoint* B)
{
if (A && B) {
return heading_true_degrees(RAD(A->latitude), RAD(A->longitude), RAD(B->latitude), RAD(B->longitude));
}
}
-geocache_data *
-waypt_alloc_gc_data(waypoint *wpt)
+geocache_data*
+waypt_alloc_gc_data(waypoint* wpt)
{
- geocache_data *res = (geocache_data *)wpt->gc_data;
+ geocache_data* res = (geocache_data*)wpt->gc_data;
if (res == &empty_gc_data) {
res = wpt->gc_data = new geocache_data;
}
}
int
-waypt_empty_gc_data(const waypoint *wpt)
+waypt_empty_gc_data(const waypoint* wpt)
{
return (wpt->gc_data == &empty_gc_data);
}
* http://hexten.net/wiki/index.php/WBT-200_Comms_Protocol
*/
-static void *fd;
-static FILE *fl;
-static char *port;
-static char *erase;
+static void* fd;
+static FILE* fl;
+static char* port;
+static char* erase;
typedef enum {
UNKNOWN, WBT200, WBT201, WSG1000
static wintec_gps_types dev_type = UNKNOWN;
struct buf_chunk {
- struct buf_chunk *next;
+ struct buf_chunk* next;
size_t size;
size_t used;
/* data follows in memory */
((void *) ((char *) buf_CHUNK_DATA(c) + (offset)))
struct buf_head {
- struct buf_chunk *head;
- struct buf_chunk *tail;
+ struct buf_chunk* head;
+ struct buf_chunk* tail;
size_t alloc;
size_t used;
/* read position */
- struct buf_chunk *current;
+ struct buf_chunk* current;
unsigned long offset;
/* shoehorned in here primarily out of laziness */
unsigned checksum;
};
struct read_state {
- route_head *route_head_;
+ route_head* route_head_;
unsigned wpn, tpn;
struct buf_head data;
};
-static void db(int l, const char *msg, ...)
+static void db(int l, const char* msg, ...)
{
va_list ap;
va_start(ap, msg);
* tidy up its interface.
*/
-static void buf_init(struct buf_head *h, size_t alloc)
+static void buf_init(struct buf_head* h, size_t alloc)
{
h->head = NULL;
h->tail = NULL;
h->offset = 0;
}
-static void buf_empty(struct buf_head *h)
+static void buf_empty(struct buf_head* h)
{
- struct buf_chunk *chunk, *next;
+ struct buf_chunk* chunk, *next;
for (chunk = h->head; chunk; chunk = next) {
next = chunk->next;
xfree(chunk);
h->checksum = 0;
}
-static void buf_rewind(struct buf_head *h)
+static void buf_rewind(struct buf_head* h)
{
h->current = h->head;
h->offset = 0;
}
-static size_t buf_read(struct buf_head *h, void *data, size_t len)
+static size_t buf_read(struct buf_head* h, void* data, size_t len)
{
- char *bp = (char *) data;
+ char* bp = (char*) data;
size_t got = 0;
while (len != 0 && h->current != NULL) {
return got;
}
-static void buf_extend(struct buf_head *h, size_t amt)
+static void buf_extend(struct buf_head* h, size_t amt)
{
- struct buf_chunk *c;
+ struct buf_chunk* c;
size_t sz = amt + sizeof(struct buf_chunk);
c = (struct buf_chunk*) xmalloc(sz);
h->tail = c;
}
-static void buf_update_checksum(struct buf_head *h, const void *data, size_t len)
+static void buf_update_checksum(struct buf_head* h, const void* data, size_t len)
{
- unsigned char *cp = (unsigned char *) data;
+ unsigned char* cp = (unsigned char*) data;
unsigned i;
db(4, "Updating checksum with %p, %lu, before: %02x ",
db(4, "after: %02x\n", h->checksum);
}
-static void buf_write(struct buf_head *h, const void *data, size_t len)
+static void buf_write(struct buf_head* h, const void* data, size_t len)
{
size_t avail;
- const char *bp = (const char *) data;
+ const char* bp = (const char*) data;
buf_update_checksum(h, data, len);
avail = len;
}
- memcpy((char *) buf_CHUNK_PTR(h->tail, h->tail->used), bp, avail);
+ memcpy((char*) buf_CHUNK_PTR(h->tail, h->tail->used), bp, avail);
h->tail->used += avail;
bp += avail;
len -= avail;
}
}
-static void rd_line(char *buf, int len)
+static void rd_line(char* buf, int len)
{
int rc;
if (rc = gbser_read_line(fd, buf, len, TIMEOUT, 0x0A, 0x0D), rc != gbser_OK) {
db(3, "Got response: \"%s\"\n", buf);
}
-static void wr_cmd(const char *cmd)
+static void wr_cmd(const char* cmd)
{
int rc;
db(3, "Sending: %s\n", cmd);
}
}
-static void wr_cmdl(const char *cmd)
+static void wr_cmdl(const char* cmd)
{
wr_cmd(cmd);
wr_cmd(NL);
}
-static int expect(const char *str)
+static int expect(const char* str)
{
int state = 0;
int c, i;
}
-static void rd_init(const char *fname)
+static void rd_init(const char* fname)
{
port = xstrdup(fname);
xfree(port);
}
-static int rd_buf(void *buf, int len)
+static int rd_buf(void* buf, int len)
{
int rc;
if (rc = gbser_read_wait(fd, buf, len, TIMEOUT), rc < 0) {
return 1;
}
-static void file_init(const char *fname)
+static void file_init(const char* fname)
{
db(1, "Opening file...\n");
if ((fl = fopen(fname, "rb")) == NULL) {
fclose(fl);
}
-static int starts_with(const char *buf, const char *pat)
+static int starts_with(const char* buf, const char* pat)
{
size_t pat_len = strlen(pat);
return (pat_len <= strlen(buf))
/* Send a command then wait for a line starting with the command string
* to be returned.
*/
-static int do_cmd(const char *cmd, const char *expect, char *buf, int len)
+static int do_cmd(const char* cmd, const char* expect, char* buf, int len)
{
int trycount;
/* Issue a command that expects the same string to be echoed
* back as an ACK
*/
-static int do_simple(const char *cmd, char *buf, int len)
+static int do_simple(const char* cmd, char* buf, int len)
{
return do_cmd(cmd, cmd, buf, len);
}
-static char *get_param(const char *cmd, char *buf, int len)
+static char* get_param(const char* cmd, char* buf, int len)
{
int cl = do_simple(cmd, buf, len);
return buf + cl + 1;
}
-static int get_param_int(const char *cmd)
+static int get_param_int(const char* cmd)
{
char buf[80];
return atoi(get_param(cmd, buf, sizeof(buf)));
}
-static double get_param_float(const char *cmd)
+static double get_param_float(const char* cmd)
{
char buf[80];
return atof(get_param(cmd, buf, sizeof(buf)));
mday > 0 && mday <= 31 && mon > 0 && mon <= 12 && year >= 4;
}
-static waypoint *make_point(double lat, double lon, double alt, time_t tim, const char *fmt, int index)
+static waypoint* make_point(double lat, double lon, double alt, time_t tim, const char* fmt, int index)
{
char wp_name[20];
- waypoint *wpt = waypt_new();
+ waypoint* wpt = waypt_new();
sprintf(wp_name, fmt, index);
return wpt;
}
-static waypoint *make_waypoint(struct read_state *st, double lat, double lon, double alt, time_t tim)
+static waypoint* make_waypoint(struct read_state* st, double lat, double lon, double alt, time_t tim)
{
return make_point(lat, lon, alt, tim, "WP%04d", ++st->wpn);
}
-static waypoint *make_trackpoint(struct read_state *st, double lat, double lon, double alt, time_t tim)
+static waypoint* make_trackpoint(struct read_state* st, double lat, double lon, double alt, time_t tim)
{
return make_point(lat, lon, alt, tim, "TP%04d", ++st->tpn);
}
-static int wbt200_data_chunk(struct read_state *st, const void *buf, int fmt)
+static int wbt200_data_chunk(struct read_state* st, const void* buf, int fmt)
{
uint32_t tim;
double lat, lon, alt;
time_t rtim;
- waypoint *tpt = NULL;
- const char *bp = (const char*) buf;
+ waypoint* tpt = NULL;
+ const char* bp = (const char*) buf;
size_t buf_used = fmt_version[fmt].reclen;
tim = le_read32(bp + 0);
}
/* Return true iff the data appears valid with the specified record length */
-static int is_valid(struct buf_head *h, int fmt)
+static int is_valid(struct buf_head* h, int fmt)
{
char buf[RECLEN_MAX];
size_t reclen = fmt_version[fmt].reclen;
return 1;
}
-static void wbt200_process_data(struct read_state *pst, int fmt)
+static void wbt200_process_data(struct read_state* pst, int fmt)
{
char buf[RECLEN_MAX];
size_t reclen = fmt_version[fmt].reclen;
}
}
-static void state_init(struct read_state *pst)
+static void state_init(struct read_state* pst)
{
pst->route_head_ = NULL;
pst->wpn = 0;
buf_init(&pst->data, RECLEN_V1 * RECLEN_V2);
}
-static void state_empty(struct read_state *pst)
+static void state_empty(struct read_state* pst)
{
buf_empty(&pst->data);
state_init(pst);
}
-static int want_bytes(struct buf_head *h, size_t len)
+static int want_bytes(struct buf_head* h, size_t len)
{
char buf[512];
state_empty(&st);
}
-static int all_null(const void *buf, const int len)
+static int all_null(const void* buf, const int len)
{
- const char *bp = (const char *) buf;
+ const char* bp = (const char*) buf;
int i;
for (i = 0; i < len; i++) {
return 1;
}
-static int wbt201_data_chunk(struct read_state *st, const void *buf)
+static int wbt201_data_chunk(struct read_state* st, const void* buf)
{
uint32_t tim;
uint16_t flags;
double lat, lon, alt;
time_t rtim;
- waypoint *tpt = NULL;
- const char *bp = (const char *) buf;
+ waypoint* tpt = NULL;
+ const char* bp = (const char*) buf;
/* Zero records are skipped */
if (all_null(buf, RECLEN_WBT201)) {
rtim = decode_date(tim);
if ((flags & WBT201_WAYPOINT) && (global_opts.masked_objective & WPTDATAMASK)) {
- waypoint *wpt = make_waypoint(st, lat, lon, alt, rtim);
+ waypoint* wpt = make_waypoint(st, lat, lon, alt, rtim);
waypt_add(wpt);
}
return 1;
}
-static void wbt201_process_chunk(struct read_state *st)
+static void wbt201_process_chunk(struct read_state* st)
{
char buf[RECLEN_WBT201];
}
}
-static int wbt201_read_chunk(struct read_state *st, unsigned pos, unsigned limit)
+static int wbt201_read_chunk(struct read_state* st, unsigned pos, unsigned limit)
{
char cmd_buf[30];
char line_buf[100];
unsigned long cs;
- char *lp, *op;
- static const char *cs_prefix = "@AL,CS,";
+ char* lp, *op;
+ static const char* cs_prefix = "@AL,CS,";
unsigned want = limit - pos;
if (want > WBT201CHUNK) {
struct read_state st;
unsigned tries;
- const char *tmp;
+ const char* tmp;
double ver_hw;
double ver_sw;
struct read_state st;
int fmt;
- const char * tk1_magic = TK1_MAGIC;
+ const char* tk1_magic = TK1_MAGIC;
size_t tk1_magic_len = strlen(tk1_magic) + 1;
state_init(&st);
#include "xmlgeneric.h"
/* argument storage */
-static char * aicicon =0;
-static char * aioicon =0;
-static char * ahcicon =0;
-static char * ahoicon =0;
-static char * snmac =0;
+static char* aicicon =0;
+static char* aioicon =0;
+static char* ahcicon =0;
+static char* ahoicon =0;
+static char* snmac =0;
static
arglist_t wfff_xml_args[] = {
static double ap_lon =0.0;
/* Start of AP block */
-void wfff_s(const char *args, const QXmlStreamAttributes* unused)
+void wfff_s(const char* args, const QXmlStreamAttributes* unused)
{
xfreez(ap_mac);
xfreez(ap_ssid);
ap_lon=0.0;
}
-void wfff_mac(const char *args, const QXmlStreamAttributes* unused)
+void wfff_mac(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
ap_mac = xstrdup(args);
}
}
-void wfff_ssid(const char *args, const QXmlStreamAttributes* unused)
+void wfff_ssid(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
ap_ssid = xstrdup(args);
}
}
-void wfff_type(const char *args, const QXmlStreamAttributes* unused)
+void wfff_type(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
ap_type = xstrdup(args);
}
}
-void wfff_mnrssi(const char *args, const QXmlStreamAttributes* unused)
+void wfff_mnrssi(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
ap_mnrssi = atof(args);
}
}
-void wfff_mxrssi(const char *args, const QXmlStreamAttributes* unused)
+void wfff_mxrssi(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
ap_mxrssi = atof(args);
}
}
-void wfff_chan(const char *args, const QXmlStreamAttributes* unused)
+void wfff_chan(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
ap_chan = atoi(args);
}
}
-void wfff_first(const char *args, const QXmlStreamAttributes* unused)
+void wfff_first(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
ap_first = xml_parse_time(args).toTime_t();
}
}
-void wfff_last(const char *args, const QXmlStreamAttributes* unused)
+void wfff_last(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
ap_last = xstrdup(args);
}
}
-void wfff_wep(const char *args, const QXmlStreamAttributes* unused)
+void wfff_wep(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
ap_wep = xstrdup(args);
}
}
-void wfff_hdop(const char *args, const QXmlStreamAttributes* unused)
+void wfff_hdop(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
ap_hdop = atof(args);
}
}
-void wfff_lat(const char *args, const QXmlStreamAttributes* unused)
+void wfff_lat(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
ap_lat = atof(args);
}
}
-void wfff_lon(const char *args, const QXmlStreamAttributes* unused)
+void wfff_lon(const char* args, const QXmlStreamAttributes* unused)
{
if (args) {
ap_lon = atof(args);
/* End of AP Block, set waypoint and add */
static long tosscount=0;
-void wfff_e(const char *args, const QXmlStreamAttributes* unused)
+void wfff_e(const char* args, const QXmlStreamAttributes* unused)
{
waypoint* wpt_tmp =0;
char desc[255] ="\0";
void
-wfff_xml_rd_init(const char *fname)
+wfff_xml_rd_init(const char* fname)
{
tosscount = 0;
static gbfile* fin;
static void
-wintec_tes_rd_init(const char *fname)
+wintec_tes_rd_init(const char* fname)
{
fin = gbfopen(fname, "r", MYNAME);
}
static void
wintec_tes_read(void)
{
- route_head *trk = route_head_alloc();
+ route_head* trk = route_head_alloc();
track_add_head(trk);
while (!gbfeof(fin)) {
- waypoint *wpt;
+ waypoint* wpt;
uint16_t flags = gbfgetuint16(fin);
uint32_t date = gbfgetuint32(fin);
int32_t latitude = gbfgetint32(fin);
// Wintec's software puts a waypoint in the track, so we
// mock that.
if (flags & 0x02) {
- waypoint *temp = waypt_dupe(wpt);
+ waypoint* temp = waypt_dupe(wpt);
waypt_add(temp);
}
#define MYNAME "XCSV"
#define ISSTOKEN(a,b) (strncmp(a,b, strlen(b)) == 0)
-static char *styleopt = NULL;
-static char *snlenopt = NULL;
-static char *snwhiteopt = NULL;
-static char *snupperopt = NULL;
-static char *snuniqueopt = NULL;
-char *prefer_shortnames = NULL;
-char *xcsv_urlbase = NULL;
-static char *opt_datum;
+static char* styleopt = NULL;
+static char* snlenopt = NULL;
+static char* snwhiteopt = NULL;
+static char* snupperopt = NULL;
+static char* snuniqueopt = NULL;
+char* prefer_shortnames = NULL;
+char* xcsv_urlbase = NULL;
+static char* opt_datum;
-static const char *intstylebuf = NULL;
+static const char* intstylebuf = NULL;
static
arglist_t xcsv_args[] = {
void
xcsv_destroy_style(void)
{
- queue *elem, *tmp;
- field_map_t *fmp;
- ogue_t *ogp;
+ queue* elem, *tmp;
+ field_map_t* fmp;
+ ogue_t* ogp;
int internal = 0;
/*
/* destroy the prologue */
QUEUE_FOR_EACH(&xcsv_file.prologue, elem, tmp) {
- ogp = (ogue_t *)elem;
+ ogp = (ogue_t*)elem;
if (ogp->val) {
xfree(ogp->val);
}
/* destroy the epilogue */
QUEUE_FOR_EACH(&xcsv_file.epilogue, elem, tmp) {
- ogp = (ogue_t *)elem;
+ ogp = (ogue_t*)elem;
if (ogp->val) {
xfree(ogp->val);
}
/* destroy the ifields */
QUEUE_FOR_EACH(&xcsv_file.ifield, elem, tmp) {
- fmp = (field_map_t *) elem;
+ fmp = (field_map_t*) elem;
if (fmp->key) {
xfree(fmp->key);
}
/* destroy the ofields, if they are not re-mapped to ifields. */
if (xcsv_file.ofield != &xcsv_file.ifield) {
QUEUE_FOR_EACH(xcsv_file.ofield, elem, tmp) {
- fmp = (field_map_t *) elem;
+ fmp = (field_map_t*) elem;
if (fmp->key) {
xfree(fmp->key);
}
xcsv_file.is_internal = internal;
}
-const char *
-xcsv_get_char_from_constant_table(char *key)
+const char*
+xcsv_get_char_from_constant_table(char* key)
{
- char_map_t *cm = xcsv_char_table;
+ char_map_t* cm = xcsv_char_table;
while ((cm->key) && (strcmp(key, cm->key) != 0)) {
cm++;
}
static void
-xcsv_parse_style_line(char *sbuff)
+xcsv_parse_style_line(char* sbuff)
{
int i, linecount = 0;
- char *s, *sp;
- char *p;
- const char *cp;
- char *key, *val, *pfc;
+ char* s, *sp;
+ char* p;
+ const char* cp;
+ char* key, *val, *pfc;
/*
* tokens should be parsed longest to shortest, unless something
/* field delimiters are always bad characters */
if (0 == strcmp(p, "\\w")) {
- char *s = xstrappend(xcsv_file.badchars, " \n\r");
+ char* s = xstrappend(xcsv_file.badchars, " \n\r");
if (xcsv_file.badchars) {
xfree(xcsv_file.badchars);
}
/* field_enclosers are always bad characters */
if (xcsv_file.badchars) {
- xcsv_file.badchars = (char *) xrealloc(xcsv_file.badchars,
- strlen(xcsv_file.badchars) +
- strlen(p) + 1);
+ xcsv_file.badchars = (char*) xrealloc(xcsv_file.badchars,
+ strlen(xcsv_file.badchars) +
+ strlen(p) + 1);
} else {
- xcsv_file.badchars = (char *) xcalloc(strlen(p) + 1, 1);
+ xcsv_file.badchars = (char*) xcalloc(strlen(p) + 1, 1);
}
strcat(xcsv_file.badchars, p);
xfree(p);
- } else
+ } else
- if (ISSTOKEN(sbuff, "RECORD_DELIMITER")) {
- sp = csv_stringtrim(&sbuff[17], "\"", 1);
- cp = xcsv_get_char_from_constant_table(sp);
- if (cp) {
- xcsv_file.record_delimiter = xstrdup(cp);
- xfree(sp);
- } else {
- xcsv_file.record_delimiter = sp;
- }
+ if (ISSTOKEN(sbuff, "RECORD_DELIMITER")) {
+ sp = csv_stringtrim(&sbuff[17], "\"", 1);
+ cp = xcsv_get_char_from_constant_table(sp);
+ if (cp) {
+ xcsv_file.record_delimiter = xstrdup(cp);
+ xfree(sp);
+ } else {
+ xcsv_file.record_delimiter = sp;
+ }
- p = csv_stringtrim(xcsv_file.record_delimiter, " ", 0);
+ p = csv_stringtrim(xcsv_file.record_delimiter, " ", 0);
- /* record delimiters are always bad characters */
- if (xcsv_file.badchars) {
- xcsv_file.badchars = (char *) xrealloc(xcsv_file.badchars,
- strlen(xcsv_file.badchars) +
- strlen(p) + 1);
- } else {
- xcsv_file.badchars = (char *) xcalloc(strlen(p) + 1, 1);
- }
+ /* record delimiters are always bad characters */
+ if (xcsv_file.badchars) {
+ xcsv_file.badchars = (char*) xrealloc(xcsv_file.badchars,
+ strlen(xcsv_file.badchars) +
+ strlen(p) + 1);
+ } else {
+ xcsv_file.badchars = (char*) xcalloc(strlen(p) + 1, 1);
+ }
- strcat(xcsv_file.badchars, p);
+ strcat(xcsv_file.badchars, p);
- xfree(p);
+ xfree(p);
- } else
-
- if (ISSTOKEN(sbuff, "FORMAT_TYPE")) {
- const char *p;
- for (p = &sbuff[11]; *p && isspace(*p); p++) {
- ;
- }
- if (ISSTOKEN(p, "INTERNAL")) {
- xcsv_file.type = ff_type_internal;
- }
- /* this is almost inconcievable... */
- if (ISSTOKEN(p, "SERIAL")) {
- xcsv_file.type = ff_type_serial;
- }
} else
- if (ISSTOKEN(sbuff, "DESCRIPTION")) {
- xcsv_file.description = csv_stringtrim(&sbuff[11],"", 0);
+ if (ISSTOKEN(sbuff, "FORMAT_TYPE")) {
+ const char* p;
+ for (p = &sbuff[11]; *p && isspace(*p); p++) {
+ ;
+ }
+ if (ISSTOKEN(p, "INTERNAL")) {
+ xcsv_file.type = ff_type_internal;
+ }
+ /* this is almost inconcievable... */
+ if (ISSTOKEN(p, "SERIAL")) {
+ xcsv_file.type = ff_type_serial;
+ }
} else
- if (ISSTOKEN(sbuff, "EXTENSION")) {
- xcsv_file.extension = csv_stringtrim(&sbuff[10],"", 0);
+ if (ISSTOKEN(sbuff, "DESCRIPTION")) {
+ xcsv_file.description = csv_stringtrim(&sbuff[11],"", 0);
} else
- if (ISSTOKEN(sbuff, "SHORTLEN")) {
- if (xcsv_file.mkshort_handle) {
- setshort_length(xcsv_file.mkshort_handle, atoi(&sbuff[9]));
- }
+ if (ISSTOKEN(sbuff, "EXTENSION")) {
+ xcsv_file.extension = csv_stringtrim(&sbuff[10],"", 0);
} else
- if (ISSTOKEN(sbuff, "SHORTWHITE")) {
+ if (ISSTOKEN(sbuff, "SHORTLEN")) {
if (xcsv_file.mkshort_handle) {
- setshort_whitespace_ok(xcsv_file.mkshort_handle, atoi(&sbuff[12]));
+ setshort_length(xcsv_file.mkshort_handle, atoi(&sbuff[9]));
}
} else
- if (ISSTOKEN(sbuff, "BADCHARS")) {
- sp = csv_stringtrim(&sbuff[9], "\"", 1);
- cp = xcsv_get_char_from_constant_table(sp);
-
- if (cp) {
- p = xstrdup(cp);
- xfree(sp);
- } else {
- p = sp;
+ if (ISSTOKEN(sbuff, "SHORTWHITE")) {
+ if (xcsv_file.mkshort_handle) {
+ setshort_whitespace_ok(xcsv_file.mkshort_handle, atoi(&sbuff[12]));
}
+ } else
- if (xcsv_file.badchars) {
- xcsv_file.badchars = (char *) xrealloc(xcsv_file.badchars,
- strlen(xcsv_file.badchars) +
- strlen(p) + 1);
- } else {
- xcsv_file.badchars = (char *) xcalloc(strlen(p) + 1, 1);
- }
+ if (ISSTOKEN(sbuff, "BADCHARS")) {
+ sp = csv_stringtrim(&sbuff[9], "\"", 1);
+ cp = xcsv_get_char_from_constant_table(sp);
- strcat(xcsv_file.badchars, p);
+ if (cp) {
+ p = xstrdup(cp);
+ xfree(sp);
+ } else {
+ p = sp;
+ }
- xfree(p);
+ if (xcsv_file.badchars) {
+ xcsv_file.badchars = (char*) xrealloc(xcsv_file.badchars,
+ strlen(xcsv_file.badchars) +
+ strlen(p) + 1);
+ } else {
+ xcsv_file.badchars = (char*) xcalloc(strlen(p) + 1, 1);
+ }
- } else
+ strcat(xcsv_file.badchars, p);
+
+ xfree(p);
- if (ISSTOKEN(sbuff, "PROLOGUE")) {
- xcsv_prologue_add(xstrdup(&sbuff[9]));
} else
- if (ISSTOKEN(sbuff, "EPILOGUE")) {
- xcsv_epilogue_add(xstrdup(&sbuff[9]));
+ if (ISSTOKEN(sbuff, "PROLOGUE")) {
+ xcsv_prologue_add(xstrdup(&sbuff[9]));
} else
- if (ISSTOKEN(sbuff, "ENCODING")) {
- p = csv_stringtrim(&sbuff[8], "\"", 1);
- cet_convert_init(p, 1);
- xfree(p);
+ if (ISSTOKEN(sbuff, "EPILOGUE")) {
+ xcsv_epilogue_add(xstrdup(&sbuff[9]));
} else
- if (ISSTOKEN(sbuff, "DATUM")) {
- p = csv_stringtrim(&sbuff[5], "\"", 1);
- xcsv_file.gps_datum = GPS_Lookup_Datum_Index(p);
- is_fatal(xcsv_file.gps_datum < 0, MYNAME ": datum \"%s\" is not supported.", p);
+ if (ISSTOKEN(sbuff, "ENCODING")) {
+ p = csv_stringtrim(&sbuff[8], "\"", 1);
+ cet_convert_init(p, 1);
xfree(p);
} else
- if (ISSTOKEN(sbuff, "DATATYPE")) {
- p = csv_stringtrim(&sbuff[8], "\"", 1);
- if (case_ignore_strcmp(p, "TRACK") == 0) {
- xcsv_file.datatype = trkdata;
- } else if (case_ignore_strcmp(p, "ROUTE") == 0) {
- xcsv_file.datatype = rtedata;
- } else if (case_ignore_strcmp(p, "WAYPOINT") == 0) {
- xcsv_file.datatype = wptdata;
- } else {
- fatal(MYNAME ": Unknown data type \"%s\"!\n", p);
- }
+ if (ISSTOKEN(sbuff, "DATUM")) {
+ p = csv_stringtrim(&sbuff[5], "\"", 1);
+ xcsv_file.gps_datum = GPS_Lookup_Datum_Index(p);
+ is_fatal(xcsv_file.gps_datum < 0, MYNAME ": datum \"%s\" is not supported.", p);
xfree(p);
-
} else
- if (ISSTOKEN(sbuff, "IFIELD")) {
- key = val = pfc = NULL;
-
- s = csv_lineparse(&sbuff[6], ",", "", linecount);
-
- i = 0;
- while (s) {
- switch (i) {
- case 0:
- /* key */
- key = csv_stringtrim(s, "\"", 1);
- break;
- case 1:
- /* default value */
- val = csv_stringtrim(s, "\"", 1);
- break;
- case 2:
- /* printf conversion */
- pfc = csv_stringtrim(s, "\"", 1);
- break;
- default:
- break;
- }
- i++;
-
- s = csv_lineparse(NULL, ",", "", linecount);
+ if (ISSTOKEN(sbuff, "DATATYPE")) {
+ p = csv_stringtrim(&sbuff[8], "\"", 1);
+ if (case_ignore_strcmp(p, "TRACK") == 0) {
+ xcsv_file.datatype = trkdata;
+ } else if (case_ignore_strcmp(p, "ROUTE") == 0) {
+ xcsv_file.datatype = rtedata;
+ } else if (case_ignore_strcmp(p, "WAYPOINT") == 0) {
+ xcsv_file.datatype = wptdata;
+ } else {
+ fatal(MYNAME ": Unknown data type \"%s\"!\n", p);
}
-
- xcsv_ifield_add(key, val, pfc);
+ xfree(p);
} else
- /*
- * as OFIELDs are implemented as an after-thought, I'll
- * leave this as it's own parsing for now. We could
- * change the world on ifield vs ofield format later..
- */
- if (ISSTOKEN(sbuff, "OFIELD")) {
- int options = 0;
+ if (ISSTOKEN(sbuff, "IFIELD")) {
key = val = pfc = NULL;
s = csv_lineparse(&sbuff[6], ",", "", linecount);
/* printf conversion */
pfc = csv_stringtrim(s, "\"", 1);
break;
- case 3:
- /* Any additional options. */
- if (strstr(s, "no_delim_before")) {
- options |= OPTIONS_NODELIM;
- }
- if (strstr(s, "absolute")) {
- options |= OPTIONS_ABSOLUTE;
- }
- if (strstr(s, "optional")) {
- options |= OPTIONS_OPTIONAL;
- }
default:
break;
}
i++;
+
s = csv_lineparse(NULL, ",", "", linecount);
}
- xcsv_ofield_add(key, val, pfc, options);
- }
+ xcsv_ifield_add(key, val, pfc);
+
+ } else
+
+ /*
+ * as OFIELDs are implemented as an after-thought, I'll
+ * leave this as it's own parsing for now. We could
+ * change the world on ifield vs ofield format later..
+ */
+ if (ISSTOKEN(sbuff, "OFIELD")) {
+ int options = 0;
+ key = val = pfc = NULL;
+
+ s = csv_lineparse(&sbuff[6], ",", "", linecount);
+
+ i = 0;
+ while (s) {
+ switch (i) {
+ case 0:
+ /* key */
+ key = csv_stringtrim(s, "\"", 1);
+ break;
+ case 1:
+ /* default value */
+ val = csv_stringtrim(s, "\"", 1);
+ break;
+ case 2:
+ /* printf conversion */
+ pfc = csv_stringtrim(s, "\"", 1);
+ break;
+ case 3:
+ /* Any additional options. */
+ if (strstr(s, "no_delim_before")) {
+ options |= OPTIONS_NODELIM;
+ }
+ if (strstr(s, "absolute")) {
+ options |= OPTIONS_ABSOLUTE;
+ }
+ if (strstr(s, "optional")) {
+ options |= OPTIONS_OPTIONAL;
+ }
+ default:
+ break;
+ }
+ i++;
+ s = csv_lineparse(NULL, ",", "", linecount);
+ }
+
+ xcsv_ofield_add(key, val, pfc, options);
+ }
}
}
* that "ignore to end of line" comments work right.
*/
static void
-xcsv_parse_style_buff(const char *sbuff)
+xcsv_parse_style_buff(const char* sbuff)
{
char ibuf[256];
- char *ibufp;
+ char* ibufp;
size_t i;
while (*sbuff) {
}
static void
-xcsv_read_style(const char *fname)
+xcsv_read_style(const char* fname)
{
- char *sbuff;
- gbfile *fp;
+ char* sbuff;
+ gbfile* fp;
xcsv_file_init();
* the xcsv parser and make it ready for general use.
*/
void
-xcsv_read_internal_style(const char *style_buf)
+xcsv_read_internal_style(const char* style_buf)
{
xcsv_file_init();
xcsv_file.is_internal = 1;
}
void
-xcsv_setup_internal_style(const char *style_buf)
+xcsv_setup_internal_style(const char* style_buf)
{
xcsv_file_init();
xcsv_destroy_style();
static void
-xcsv_rd_init(const char *fname)
+xcsv_rd_init(const char* fname)
{
/*
}
static void
-xcsv_wr_init(const char *fname)
+xcsv_wr_init(const char* fname)
{
/* if we don't have an internal style defined, we need to
* read it from a user-supplied style file, or die trying.
}
xcsv_file.xcsvfp = gbfopen(fname, "w", MYNAME);
- xcsv_file.fname = (char *)fname;
+ xcsv_file.fname = (char*)fname;
/* set mkshort options from the command line */
if (global_opts.synthesize_shortnames) {
}
static void
-xcsv_wr_position_init(const char *fname)
+xcsv_wr_position_init(const char* fname)
{
xcsv_wr_init(fname);
}
static void
-xcsv_wr_position(waypoint *wpt)
+xcsv_wr_position(waypoint* wpt)
{
/* Tweak incoming name if we don't have a fix */
switch (wpt->fix) {
};
#else
-void xcsv_read_internal_style(const char *style_buf) {}
-void xcsv_setup_internal_style(const char *style_buf) {}
+void xcsv_read_internal_style(const char* style_buf) {}
+void xcsv_setup_internal_style(const char* style_buf) {}
#endif //CSVFMTS_ENABLED
-const char *xhtml_entities =
+const char* xhtml_entities =
"<!-- Portions (C) International Organization for Standardization 1986\n"
" Permission to copy in any form is granted for use with\n"
" conforming SGML systems and applications as defined in\n"
{
char* tmp_ent = xml_entitize(CSTRE(value));
gbfprintf(ofd, "%s<%s>%s</%s>\n", CSTRE(indent), CSTRE(tag), tmp_ent,
- CSTRE(tag));
+ CSTRE(tag));
xfree(tmp_ent);
}
const QString& attrval)
{
gbfprintf(ofd, "%s<%s %s=\"%s\">\n", CSTRE(indent), CSTRE(tag), CSTRE(attr),
- CSTRE(attrval));
+ CSTRE(attrval));
}
void
const QString& attrval2)
{
gbfprintf(ofd, "%s<%s %s=\"%s\" %s=\"%s\">\n", CSTRE(indent), CSTRE(tag),
- CSTRE(attr1), CSTRE(attrval1), CSTRE(attr2), CSTRE(attrval2));
+ CSTRE(attr1), CSTRE(attrval1), CSTRE(attr2), CSTRE(attrval2));
}
void
xg_tag_tbl = tbl;
xg_encoding = encoding;
if (encoding) {
- QTextCodec *tcodec = QTextCodec::codecForName(encoding);
+ QTextCodec* tcodec = QTextCodec::codecForName(encoding);
if (tcodec) {
codec = tcodec;
}
switch (reader.tokenType()) {
case QXmlStreamReader::StartDocument:
if (!reader.documentEncoding().isEmpty()) {
- codec = QTextCodec::codecForName( CSTR(reader.documentEncoding().toString()) );
+ codec = QTextCodec::codecForName(CSTR(reader.documentEncoding().toString()));
}
if (codec == NULL) {
// According to http://www.opentag.com/xfaq_enc.htm#enc_default , we
#include "defs.h"
static void
-free_xml_tag(xml_tag *tag)
+free_xml_tag(xml_tag* tag)
{
- xml_tag *next = NULL;
- char **ap;
+ xml_tag* next = NULL;
+ char** ap;
while (tag) {
if (tag->cdata) {
}
static void
-copy_xml_tag(xml_tag **copy, xml_tag *src, xml_tag *parent)
+copy_xml_tag(xml_tag** copy, xml_tag* src, xml_tag* parent)
{
- xml_tag *res = NULL;
- char **ap = NULL;
- char **ap2 = NULL;
+ xml_tag* res = NULL;
+ char** ap = NULL;
+ char** ap2 = NULL;
int count = 0;
if (!src) {
count++;
ap++;
}
- res->attributes = (char **)xcalloc(count+1, sizeof(char *));
+ res->attributes = (char**)xcalloc(count+1, sizeof(char*));
ap = src->attributes;
ap2 = res->attributes;
while (*ap) {
}
static void
-convert_xml_tag(xml_tag *tag)
+convert_xml_tag(xml_tag* tag)
{
- char **ap = NULL;
+ char** ap = NULL;
if (tag == NULL) {
return;
convert_xml_tag(tag->child);
}
-fs_xml *fs_xml_alloc(long type);
+fs_xml* fs_xml_alloc(long type);
static void
-fs_xml_destroy(void *fs)
+fs_xml_destroy(void* fs)
{
- fs_xml *xml = (fs_xml *)fs;
+ fs_xml* xml = (fs_xml*)fs;
if (xml) {
free_xml_tag(xml->tag);
}
}
static void
-fs_xml_copy(void **copy, void *source)
+fs_xml_copy(void** copy, void* source)
{
- fs_xml *src = (fs_xml *)source;
+ fs_xml* src = (fs_xml*)source;
if (!source) {
*copy = NULL;
return;
}
- *copy = (void *)fs_xml_alloc(src->fs.type);
+ *copy = (void*)fs_xml_alloc(src->fs.type);
memcpy(*copy, source, sizeof(fs_xml));
- copy_xml_tag(&(((fs_xml *)(*copy))->tag), src->tag, NULL);
+ copy_xml_tag(&(((fs_xml*)(*copy))->tag), src->tag, NULL);
}
static void
-fs_xml_convert(void *fs)
+fs_xml_convert(void* fs)
{
- fs_xml *xml = (fs_xml *)fs;
+ fs_xml* xml = (fs_xml*)fs;
if (xml) {
convert_xml_tag(xml->tag);
}
}
-fs_xml *fs_xml_alloc(long type)
+fs_xml* fs_xml_alloc(long type)
{
- fs_xml *result = NULL;
+ fs_xml* result = NULL;
- result = (fs_xml *)xcalloc(1, sizeof(fs_xml));
+ result = (fs_xml*)xcalloc(1, sizeof(fs_xml));
result->fs.type = type;
result->fs.copy = fs_xml_copy;
result->fs.destroy = fs_xml_destroy;
#include "jeeps/gpsmath.h"
#include "garmin_tables.h"
-static waypoint *wpt;
-static route_head *trk;
-static gbfile *fout;
+static waypoint* wpt;
+static route_head* trk;
+static gbfile* fout;
static int space;
static bounds all_bounds;
static short_handle short_h;
static void
-xol_overlay(const char *args, const QXmlStreamAttributes* attrv)
+xol_overlay(const char* args, const QXmlStreamAttributes* attrv)
{
if (attrv->hasAttribute("version")) {
if (attrv->value("version") != "1.0") {
}
static void
-xol_shape(const char *args, const QXmlStreamAttributes* attrv)
+xol_shape(const char* args, const QXmlStreamAttributes* attrv)
{
if (attrv->hasAttribute("type")) {
if (attrv->value("type") == "waypoint") {
}
static void
-xol_shape_end(const char *args, const QXmlStreamAttributes* unused)
+xol_shape_end(const char* args, const QXmlStreamAttributes* unused)
{
if (wpt) {
if (trk) {
}
static void
-xol_waypt(const char *args, const QXmlStreamAttributes* attrv)
+xol_waypt(const char* args, const QXmlStreamAttributes* attrv)
{
int x=0, y=0;
}
static void
-xol_rd_init(const char *fname)
+xol_rd_init(const char* fname)
{
trk = NULL;
wpt = NULL;
/* writer */
static void
-xol_fatal_outside(const waypoint *wpt)
+xol_fatal_outside(const waypoint* wpt)
{
gbfprintf(fout, "#####\n");
fatal(MYNAME ": %s (%s) is outside of convertable area \"%s\"!\n",
static void
-xol_write_time(const waypoint *wpt)
+xol_write_time(const waypoint* wpt)
{
QString time_string = wpt->CreationTimeXML();
if (!time_string.isEmpty()) {
}
static void
-xol_write_string(const char *name, const char *str)
+xol_write_string(const char* name, const char* str)
{
if (str && *str) {
- char *temp = strenquote(str, '"');
+ char* temp = strenquote(str, '"');
gbfprintf(fout, " %s=%s", name, temp);
xfree(temp);
}
}
static void
-xol_waypt_bound_calc(const waypoint *wpt)
+xol_waypt_bound_calc(const waypoint* wpt)
{
waypt_add_to_bounds(&all_bounds, wpt);
}
static void
-xol_wr_init(const char *fname)
+xol_wr_init(const char* fname)
{
fout = gbfopen(fname, "w", MYNAME);
}
static void
-xol_waypt_disp_cb(const waypoint *wpt)
+xol_waypt_disp_cb(const waypoint* wpt)
{
double x, y;
- char *name;
+ char* name;
name = wpt->shortname;
if ((name == NULL) || (*name == '\0') || global_opts.synthesize_shortnames) {
}
static void
-xol_track_hdr_disp_cb(const route_head *trk)
+xol_track_hdr_disp_cb(const route_head* trk)
{
gbfprintf(fout, "%*s<shape type=\"polyline\"", space++*2, "");
xol_write_string("name", trk->rte_name);
}
static void
-xol_track_tlr_disp_cb(const route_head *trk)
+xol_track_tlr_disp_cb(const route_head* trk)
{
gbfprintf(fout, "%*s</waypoints>\n", --space*2, "");
gbfprintf(fout, "%*s</shape>\n", --space*2, "");
}
static void
-xol_trkpt_disp_cb(const waypoint *wpt)
+xol_trkpt_disp_cb(const waypoint* wpt)
{
double x, y;
#include "defs.h"
#include "xmlgeneric.h"
-static waypoint *wpt_tmp;
-static char *as;
+static waypoint* wpt_tmp;
+static char* as;
#define MYNAME "yahoo"
};
static void
-yahoo_rd_init(const char *fname)
+yahoo_rd_init(const char* fname)
{
xml_init(fname, gl_map, NULL);
}
}
static void
-yahoo_wr_init(const char *fname)
+yahoo_wr_init(const char* fname)
{
fatal("Writing file of type %s is not supported\n", MYNAME);
}
-void wpt_s(const char *args, const QXmlStreamAttributes* unused)
+void wpt_s(const char* args, const QXmlStreamAttributes* unused)
{
wpt_tmp = waypt_new();
}
-void wpt_e(const char *args, const QXmlStreamAttributes* unused)
+void wpt_e(const char* args, const QXmlStreamAttributes* unused)
{
waypt_add(wpt_tmp);
wpt_tmp = NULL;
}
-void wpt_lat(const char *args, const QXmlStreamAttributes* unused)
+void wpt_lat(const char* args, const QXmlStreamAttributes* unused)
{
wpt_tmp->latitude = atof(args);
}
-void wpt_lon(const char *args, const QXmlStreamAttributes* unused)
+void wpt_lon(const char* args, const QXmlStreamAttributes* unused)
{
wpt_tmp->longitude = atof(args);
}
-void wpt_addr(const char *args, const QXmlStreamAttributes* unused)
+void wpt_addr(const char* args, const QXmlStreamAttributes* unused)
{
if (wpt_tmp->notes) {
wpt_tmp->notes = xstrappend(wpt_tmp->notes, as);